txn<T> method

Future<void> txn<T>(
  1. Future<T> action()
)

Completes the provided action as a ScopedDriftProvider transaction.

Implementation

Future<void> txn<T>(Future<T> Function() action) async {
  await _caught(
    _scoped.wrapped((db) async {
      return await WebUtils.protect(tag: '${_scoped.db?.userId}', () async {
        if (isClosed || _scoped.isClosed) {
          return null;
        }

        return await _caught(db.transaction(action));
      });
    }),
  );
}