DatabaseConnectable

protocol DatabaseConnectable : EventLoopGroup
  • Performs a transaction on the referenced database.

    conn.transaction(on: .mysql) { conn in
        ...
    }
    

    Declaration

    Swift

    public func transaction<Database, T>(on db: DatabaseIdentifier<Database>, _ closure: @escaping (Database.Connection) throws -> Future<T>) -> Future<T>
        where Database: TransactionSupporting

    Parameters

    db

    DatabaseIdentifier to perform the transaction on.

    closure

    Closure to perform within the database transaction.

    Return Value

    A future containing the closure result.