iOS 数据库 canDB.swift

码农软件 · 软件分类 · iOS 数据库 · 2019-05-22 08:57:34

软件介绍

canDB.swift 是一个框架,作用类似 nonSQL 的数据库,但运作在 sqlite(FMDB) 。

    // loading the json
    let filePath = NSBundle.mainBundle().pathForResource("data", ofType:"json")    let data = NSData(contentsOfFile:filePath!, options:NSDataReadingOptions.DataReadingUncached, error:nil)    let dataArray:Array = NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.allZeros, error: nil) as! Array<Dictionary<String, String>>

    // singleton instance
    let storeInstance = canDB.sharedInstance    // saving the data, the can is automatically created if not exists
    storeInstance.saveData("Person", data: dataArray, idString: kCanDBDefaultIdString, error: nil)    // adding the index for future queries and reindexing the table
    storeInstance.addIndex("Person", indexes: ["Name"], error: nil)
    storeInstance.reIndex("Person", idString: kCanDBDefaultIdString)    let result = storeInstance.loadData("Person")    for item in result {        for (key, value) in (item as! NSDictionary) {
            println("\(key): \(value)")
        }
    }    // custom query using the previous created index "Name"
    let resultWithQuery = storeInstance.loadDataWithQuery("SELECT * FROM Person WHERE Name='John'")    for item in resultWithQuery {        for (key, value) in (item as! NSDictionary) {
            println("\(key): \(value)")
        }
    }

    storeInstance.removeDataForId("Person", idString: kCanDBDefaultIdString, idsToDelete: ["17", "19"], error: nil)

本文地址:https://codercto.com/soft/d/6280.html

突破之道

突破之道

(美)基思 R. 麦克法兰(Keith R. McFarland) / 江南、江维 / 机械工业出版社 / 2017-4 / 49.00

《从优秀到卓越》前传。 深入调查7000多家公司、1500多名关键管理人员,总结提炼出6大突破式发展策略。 解析创业成功后的公司如何腾飞,以几何速度增长,突破10亿关口。 阐述为什么创始人自己才是企业实现突破的最大障碍。一起来看看 《突破之道》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器