Latest 2.0.0.4
Homepage https://github.com/Fidetro/SwiftFFDB
License MIT
Platforms ios 8.0
Dependencies FMDB
Authors

中文文档

SwiftFFDB
SwiftFFDB SwiftFFDB SwiftFFDB SwiftFFDB

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

Wiki

More examples of usage in the wiki(unfinished)

Requirements

iOS

  • Build Swift4.0 releases toolchain
  • Deployment on iOS 8 or above
  • depend FMDB

Perfect-Swift-Server

  • Build Swift4.0.3 releases toolchain
  • Perfect-Server v3
  • depend PerfectMySQL

Installing

CocoaPod

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

Swift Package Manager

import PackageDescription

let package = Package(
    name: "PatchServer",
    dependencies: [
          .Package(url: "https://github.com/Fidetro/PerfectFFDB.git",versions: Version(0, 0, 0)..<Version(1, .max, .max))]
)

Useage

Setting

You can check out the example project
if you use in iOS:

Person.registerTable() //create table

or Perfect-server:

    PerfectMySQLConnect(host: "", user: "", password: "", db: "").setup(complete: { (mysql) in
        Person.registerTable() //create table
    })

Create

create table model would you look like this:

struct Person:FFObject {
    var primaryID: Int64?

    var name : String?

    static func memoryPropertys() -> [String]? {
        return nil
    }

    static func customColumnsType() -> [String : String]? {
        return nil
    }

    static func customColumns() -> [String : String]? {
        return nil
    }

    static func autoincrementColumn() -> String? {
        return "primaryID"
    }
}

Insert

var person = Person()
person.name = "fidetro"
person.insert()

Select

// find all Object
Person.select(where: nil)
// find name is 'fidetro' 
Person.select(where: "name = 'fidetro'")

Update

// update name is 'fidetro' to 'ffdb'
Person.update(set: "name = ?", where: "name = ?", values: ["ffdb","fidetro"])  

Delete

// 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'")

Architecture

SwiftFFDB

Support

SwiftFFDB is a personal open source project,but I happy to answer questions in Issues or email to [email protected]

Latest podspec

{
    "name": "SwiftFFDB",
    "version": "2.0.0.4",
    "summary": "a Object/Relational Mapping (ORM) support to iOS and Perfect-Server library.",
    "homepage": "https://github.com/Fidetro/SwiftFFDB",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "fidetro": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/Fidetro/SwiftFFDB.git",
        "tag": "2.0.0.4"
    },
    "source_files": [
        "Sources",
        "Sources/*.{swift}"
    ],
    "libraries": "sqlite3",
    "dependencies": {
        "FMDB": [
            "~> 2.7.2"
        ]
    }
}

Pin It on Pinterest

Share This