transaction<T> abstract method

Future<T> transaction<T>(
  1. void setResult(
    1. DbTransaction tx,
    2. void (
      1. T res
      )
    )
)

Runs the provided non-async function inside a transaction.

The function may not use async/await otherwise the transaction may commit before the queries are actually executed. This is a limitation of some adapters, that the function passed to the transaction runs "synchronously" through callbacks without releasing the event loop.

Implementation

Future<T> transaction<T>(
  void Function(DbTransaction tx, void Function(T res)) setResult,
);