transaction<T> method

Future<T> transaction<T>(
  1. Future<T> delegate(
    1. DatabaseContext context
    )
)
inherited

Executes delegate inside of a database transaction.

If transaction is called from inside of another transaction's delegate, the parent transaction / database context will be forwarded so methods using transaction can be combined into larger transactions.

Implementation

Future<T> transaction<T>(
    Future<T> Function(DatabaseContext context) delegate) async {
  return await _adapter.useConnection((connection) async {
    return await connection.runTransaction(delegate);
  });
}