writeTransaction<T> method

  1. @override
Future<T> writeTransaction<T>(
  1. Future<T> callback(
    1. SqliteWriteContext tx
    ), {
  2. Duration? lockTimeout,
})
override

Open a read-write transaction on this write context.

When called on a SqliteConnection, this takes a global lock - only one write write transaction can execute against the database at a time. This applies even when constructing separate SqliteDatabase instances for the same database file.

Statements within the transaction must be done on the provided SqliteWriteContext - attempting statements on the SqliteConnection instance will error. It is forbidden to use the SqliteWriteContext after the callback completes.

Implementation

@override
Future<T> writeTransaction<T>(
    Future<T> Function(SqliteWriteContext tx) callback,
    {Duration? lockTimeout}) async {
  return writeLock((ctx) async {
    return ctx.writeTransaction(callback);
  }, lockTimeout: lockTimeout, debugContext: 'writeTransaction()');
}