transaction
Executes a block of code within a managed transaction scope.
The transaction follows a "fail-fast" commit policy:
Success: If the
blockreturns DataResult.Success, the transaction is committed.Failure: If the
blockreturns DataResult.Failure, the transaction is automatically rolled back.Exception: If the
blockthrows any exception, the transaction is rolled back, and the exception is translated to DataResult.Failure.
Warning: Since in the underlying implementation the transaction state is bound to the current thread via ThreadLocal. The tx object provided to the block is typically the same instance as the main DataAccess object. While you should prefer using tx for clarity, calling methods directly on the DataAccess instance inside the block will also participate in the same transaction, provided they are executed on the same thread. Conversely, launching new threads or coroutines with different dispatchers inside the block will NOT automatically participate in the transaction.
Return
The result of the block as DataResult.
Parameters
The return type of the result encapsulated in DataResult.
Specifies how this transaction should behave if another transaction is already active.
A lambda providing QueryOperations context for performing database operations within the transaction.