Latest 1.0.7
Homepage https://github.com/wangmengling/Storage
License MIT
Platforms ios 9.0
Authors

Storage[Beta]

Environment Ios,Swift4

Beta version, the current can not be used for production, there are many bugs

Storage is a mobile database that runs directly inside phones, tablets or wearables. 
This repository holds the source code for the iOS versions of Storage Swift 

usage

Will use Codable and StorageProtocol [Must use]

struct StorageModel:Codable {
    var name: String
    var eMail: Int?
}

extension StorageModel:StorageProtocol {
    func primaryKey() -> String {
        return "name"
    }
}
var storageModel:StorageModel = StorageModel(name:"sd2", eMail: 2)
var storage:Storage = Storage()

Select

Insert

Update

Delete

Select

Select single data

let value:StorageModel?  =  storage.object().filters("").sorted("").value(StorageModel.self)

Select many data

let value:[StorageModel]  =  storage.object().filters("").sorted("").valueOfArray(StorageModel.self)

Insert

Insert single data

let status = storage.add(storageModel) //Add enty

Insert single data , Value is [String:Any] ,Type is inherit Codable Protocol

let status = storage.create(StorageModel.self, value: ["name":"wangmaoling","eMail":654321])

Insert many data

let status = storage.addArray([storageModel])

Insert many data , Value is [[String:Any]] ,Type is inherit Codable Protocol

let dic = [["name":"wangmaoling","eMail":123456],["name":"wangguozhong","eMail":123456]]
let status = storage.create(StorageModel.self, value: dic)

Update

Requires inheritance protocol StorageProtocol

let status = storage.update(storageModel)

Update

let status = storage.update(StorageModel.self, ["name":"wangguozhongss"]).filter(["eMail":123456]).sorted("name", ascending: true).limit(1).execute()

Delete

Delete single data

let status = storage.delete(storageModel)

Delete many data

let status = storage.delete(StorageModel.self).filter(["name":"sdsd"]).sorted("name").limit(1).execute()

Delete all data of StorageModel type

let status = storage.deleteAll(StorageModel.self)

Latest podspec

{
    "name": "StorageSwift",
    "version": "1.0.7",
    "summary": "Storage is a mobile database.",
    "description": "Storage is a mobile database: a replacement for Core Data & SQLite",
    "homepage": "https://github.com/wangmengling/Storage",
    "swift_version": "4.0.0",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "wangmengling": "[email protected]"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/wangmengling/Storage.git",
        "tag": "1.0.7"
    },
    "source_files": "Source/*.{h,m,swift}"
}

Pin It on Pinterest

Share This