a Object/Relational Mapping (ORM) support to iOS and MacOS .Since SwiftFFDB is build on top of FMDB.
SwiftFFDB is a Object/Relational Mapping (ORM) support to iOS and Perfect-Server library.Since SwiftFFDB is build on top of FMDB.
if you use Objective-C,you can use FFDB
More examples of usage in the wiki(unfinished)
SwiftFFDB can be installed using CocoaPod
$ vim Podfile
Then,edit the Podfile,add SwiftFFDB:
platform :ios, '8.0'
target 'YouApp' do
use_frameworks!
pod 'SwiftFFDB'
end
You can check out the example project
if you use in iOS:
Person.registerTable() //create table
create table model would you look like this:
struct Person:FFObject {
var primaryID: Int64?
var name : String?
static func ignoreProperties() -> [String]? {
return nil
}
static func customColumnsType() -> [String : String]? {
return nil
}
static func customColumns() -> [String : String]? {
return nil
}
static func autoincrementColumn() -> String? {
return "primaryID"
}
}
var person = Person()
person.name = "fidetro"
person.insert()
// find all Object
Person.select(where: nil)
// find name is 'fidetro'
Person.select(where: "name = 'fidetro'")
// update name is 'fidetro' to 'ffdb'
Person.update(set: "name = ?", where: "name = ?", values: ["ffdb","fidetro"])
// find name is 'fidetro'
let personList = Person.select(where: "name = 'fidetro'")
for (let person in personList){
// delete this person in database
person.delete()
}
also you can:
FFDBManager.delete(Person.self, where: "name = 'fidetro'")
SwiftFFDB
is a personal open source project,but I happy to answer questions in Issues or email to [email protected]