Database
protocol Database
Protocol used to define the Database, configurations and operations.
-
Configure database for the current instance.
Note
Should called only once.Declaration
Swift
func configure() -
Obtains a new instance of type
T.Declaration
Swift
func newObject<T>() -> T where T : Model -
Deletes an object from the Database. Once the object is deleted it is considered invalidated.
Declaration
Swift
func deleteObject<T>(_ object: T) where T : ModelParameters
objectThe object to be deleted.
-
Obtains the instance of type
Tcorresponding the Unique ID passed by argument.Declaration
Swift
func object<T>(_ type: T.Type, uniqueID id: String) -> T? where T : ModelParameters
typeThe type of the object to be found and returned.
idThe Unique ID of the object.
Return Value
The object that was found or
nilif it wasn’t found. -
Obtains the instance of type
Tcorresponding the Primary Key passed by argument.Declaration
Swift
func object<T>(_ type: T.Type, primaryKey pkValue: T.PrimaryKeyType) throws -> T? where T : ModelParameters
typeThe type of the object to be found and returned.
primaryKeyThe Primary Key of the object.
Return Value
The object that was found or
nilif it wasn’t found. -
Create a new query for model of type
T.Declaration
Swift
func query<T>(_ entity: T.Type) -> DatabaseQuery<T> where T : ModelParameters
typeThe type of the object to be searched.
Return Value
The query instance of type
DatabaseQuery. -
Adds a notification handler for changes made to this Database, and returns a notification token.
Note
You must retain the returned token for as long as you want updates to be sent to the block. To stop receiving updates, callinvalidate()on the token.Declaration
Swift
func observe(handler: @escaping DatabaseObserverToken.Handler) -> DatabaseObserverTokenParameters
blockA block which is called to process notifications.
Return Value
A token which must be held for as long as you wish to continue receiving change notifications.
View on GitHub
Install in Dash
Database Protocol Reference