Connection
public protocol Connection : AnyObject
Defines the protocol which all database plugins must implement.
-
The
QueryBuilderwith connection specific substitutions.Declaration
Swift
var queryBuilder: QueryBuilder { get } -
Establish a connection with the database.
Declaration
Swift
func connect(onCompletion: @escaping (QueryResult) -> ())Parameters
onCompletionThe function to be called when the connection call completes.
-
Establish a connection with the database.
Declaration
Swift
func connectSync() -> QueryResultReturn Value
A QueryResult indicating success or error.
-
Close the connection to the database.
Declaration
Swift
func closeConnection() -
An indication whether there is a connection to the database.
Declaration
Swift
var isConnected: Bool { get } -
Execute a query.
Declaration
Swift
func execute(query: Query, onCompletion: @escaping ((QueryResult) -> ()))Parameters
queryThe query to execute.
onCompletionThe function to be called when the execution of the query has completed.
-
Execute a raw query.
Declaration
Swift
func execute(_ raw: String, onCompletion: @escaping ((QueryResult) -> ()))Parameters
rawA String with the query to execute.
onCompletionThe function to be called when the execution of the query has completed.
-
execute(query:Default implementationparameters: onCompletion: ) Execute a query with parameters.
Default Implementation
Undocumented
Declaration
Swift
func execute(query: Query, parameters: [Any?], onCompletion: @escaping ((QueryResult) -> ()))Parameters
queryThe query to execute.
parametersAn array of the parameters.
onCompletionThe function to be called when the execution of the query has completed.
-
Execute a raw query with parameters.
Declaration
Swift
func execute(_ raw: String, parameters: [Any?], onCompletion: @escaping ((QueryResult) -> ()))Parameters
rawA String with the query to execute.
parametersAn array of the parameters.
onCompletionThe function to be called when the execution of the query has completed.
-
Execute a query with parameters.
Declaration
Swift
func execute(query: Query, parameters: [String : Any?], onCompletion: @escaping ((QueryResult) -> ()))Parameters
queryThe query to execute.
parametersA dictionary of the parameters with parameter names as the keys.
onCompletionThe function to be called when the execution of the query has completed.
-
Execute a raw query with parameters.
Declaration
Swift
func execute(_ raw: String, parameters: [String : Any?], onCompletion: @escaping ((QueryResult) -> ()))Parameters
rawA String with the query to execute.
parametersA dictionary of the parameters with parameter names as the keys.
onCompletionThe function to be called when the execution of the query has completed.
-
Prepare statement.
Declaration
Swift
func prepareStatement(_ query: Query, onCompletion: @escaping ((QueryResult) -> ()))Parameters
queryThe query to prepare statement for.
onCompletionThe function to be called when the statement has been prepared.
-
Prepare statement.
Declaration
Swift
func prepareStatement(_ raw: String, onCompletion: @escaping ((QueryResult) -> ()))Parameters
rawA String with the query to prepare statement for.
onCompletionThe function to be called when the statement has been prepared.
-
Execute a prepared statement.
Declaration
Swift
func execute(preparedStatement: PreparedStatement, onCompletion: @escaping ((QueryResult) -> ()))Parameters
preparedStatementThe prepared statement to execute.
onCompletionThe function to be called when the execution has completed.
-
Execute a prepared statement with parameters.
Declaration
Swift
func execute(preparedStatement: PreparedStatement, parameters: [Any?], onCompletion: @escaping ((QueryResult) -> ()))Parameters
preparedStatementThe prepared statement to execute.
parametersAn array of the parameters.
onCompletionThe function to be called when the execution has completed.
-
Execute a prepared statement with parameters.
Declaration
Swift
func execute(preparedStatement: PreparedStatement, parameters: [String : Any?], onCompletion: @escaping ((QueryResult) -> ()))Parameters
preparedStatementThe prepared statement to execute.
parametersA dictionary of the parameters with parameter names as the keys.
onCompletionThe function to be called when the execution has completed.
-
Release a prepared statement.
Declaration
Swift
func release(preparedStatement: PreparedStatement, onCompletion: @escaping ((QueryResult) -> ()))Parameters
preparedStatementThe prepared statement to release.
onCompletionThe function to be called when the execution has completed.
-
Return a String representation of the query.
Throws
QueryError.syntaxError if query build fails.Declaration
Swift
func descriptionOf(query: Query) throws -> StringParameters
queryThe query.
Return Value
A String representation of the query.
-
Start a transaction.
Declaration
Swift
func startTransaction(onCompletion: @escaping ((QueryResult) -> ()))Parameters
onCompletionThe function to be called when the execution of start transaction command has completed.
-
Commit the current transaction.
Declaration
Swift
func commit(onCompletion: @escaping ((QueryResult) -> ()))Parameters
onCompletionThe function to be called when the execution of commit transaction command has completed.
-
Rollback the current transaction.
Declaration
Swift
func rollback(onCompletion: @escaping ((QueryResult) -> ()))Parameters
onCompletionThe function to be called when the execution of rolback transaction command has completed.
-
Create a savepoint.
Declaration
Swift
func create(savepoint: String, onCompletion: @escaping ((QueryResult) -> ()))Parameters
savepointThe name to be given to the created savepoint.
onCompletionThe function to be called when the execution of create savepoint command has completed.
-
Rollback the current transaction to the specified savepoint.
Declaration
Swift
func rollback(to savepoint: String, onCompletion: @escaping ((QueryResult) -> ()))Parameters
onCompletionThe function to be called when the execution of rolback transaction command has completed.
-
Release a savepoint.
Declaration
Swift
func release(savepoint: String, onCompletion: @escaping ((QueryResult) -> ()))Parameters
savepointThe name of the savepoint to release.
onCompletionThe function to be called when the execution of release savepoint command has completed.
-
runCompletionHandler(_:Extension methodonCompletion: ) Undocumented
Declaration
Swift
func runCompletionHandler(_ result: QueryResult, onCompletion: @escaping ((QueryResult) -> ())) -
runCompletionHandlerRetainingConnection(result:Extension methodonCompletion: ) Undocumented
Declaration
Swift
func runCompletionHandlerRetainingConnection(result: QueryResult, onCompletion: @escaping ((QueryResult) -> ()))
View on GitHub
Connection Protocol Reference