runInTransaction<R> method

R runInTransaction<R>(
  1. TxMode mode,
  2. R fn()
)

Executes a given function inside a transaction. Returns fn's result. Aborts a transaction and rethrows on exception or if fn is asynchronous.

A transaction can group several operations into a single unit of work that either executes completely or not at all. The advantage of explicit transactions over the bulk put operations is that you can perform any number of operations and use objects of multiple boxes. In addition, you get a consistent (transactional) view on your data while the transaction is in progress.

Implementation

@pragma('vm:prefer-inline')
R runInTransaction<R>(TxMode mode, R Function() fn) =>
    Transaction.execute(this, mode, fn);