Create a gist now

Instantly share code, notes, and snippets.

@ennioma /realm_api.swift Secret
Last active Jul 6, 2017

What would you like to do?
/*
Operations on context
*/
protocol StorageContext {
/*
Create a new object with default values
return an object that is conformed to the `Storable` protocol
*/
func create<T: Storable>(_ model: T.Type, completion: @escaping ((T) -> Void)) throws
/*
Save an object that is conformed to the `Storable` protocol
*/
func save(object: Storable) throws
/*
Update an object that is conformed to the `Storable` protocol
*/
func update(block: @escaping () -> ()) throws
/*
Delete an object that is conformed to the `Storable` protocol
*/
func delete(object: Storable) throws
/*
Delete all objects that are conformed to the `Storable` protocol
*/
func deleteAll<T: Storable>(_ model: T.Type) throws
/*
Return a list of objects that are conformed to the `Storable` protocol
*/
func fetch<T: Storable>(_ model: T.Type, predicate: NSPredicate?, sorted: Sorted?, completion: (([T]) -> ()))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment