Skip to content

SQLiteFetchable

Jeff Hurray edited this page Apr 25, 2016 · 1 revision

##Overview SQLiteFetchable exposes an interface for retrieving rows from the database and converting them into model instances which are returned.

####Find Fetches by localID from the database or from the cache.
Executes on current thread and on background thread respectively.

static func find(id: SQLiteModelID) throws -> Self
static func findInBackground(id: SQLiteModelID, completion: (Self?, SQLiteModelError?) -> Void)

####Fetch All Fetches all rows from the database, converts them into models, and returns them after caching.
Executes on current thread and on background thread respectively.

static func fetchAll() throws -> [Self]
static func fetchAllInBackground(completion: ([Self], SQLiteModelError?) -> Void)

####Fetch Fetches all rows that satisfy the query from the database, converts them into models, and returns them after caching.
Executes on current thread and on background thread respectively.

static func fetch(query: QueryType) throws -> [Self]
static func fetchInBackground(query: QueryType, completion: ([Self], SQLiteModelError?) -> Void)

public protocol SQLiteFetchable {
    static func find(id: SQLiteModelID) throws -> Self
    static func findInBackground(id: SQLiteModelID, completion: (Self?, SQLiteModelError?) -> Void)
    
    static func fetchAll() throws -> [Self]
    static func fetchAllInBackground(completion: ([Self], SQLiteModelError?) -> Void)
    
    static func fetch(query: QueryType) throws -> [Self]
    static func fetchInBackground(query: QueryType, completion: ([Self], SQLiteModelError?) -> Void)
}
Clone this wiki locally