runInTransaction method

Future<void> runInTransaction (
  1. Future<void> callback(
    1. SqlTransaction sqlTransaction
    ),
  2. {Duration timeout}
)

Runs the function in a transaction.

await sqlClient.runInTransaction((sqlClient) {
  // ...
}, timeout: Duration(seconds:2));

Implementation

Future<void> runInTransaction(
  Future<void> Function(SqlTransaction sqlTransaction) callback, {
  Duration timeout,
}) {
  return SqlTransactionRequest(
    sqlClient: this,
    callback: callback,
    timeout: timeout,
  ).delegateTo(database.adapter);
}