transaction

abstract fun <T> transaction(propagation: TransactionPropagation = TransactionPropagation.REQUIRED, block: (tx: QueryOperations) -> DataResult<T>): DataResult<T>

Executes the given block of code within a new, managed transaction.

Ensures that all operations inside the block are executed atomically. The transaction will be committed only if the block completes successfully and returns DataResult.Success. In any other case (returning DataResult.Failure or throwing an exception), the transaction will be automatically rolled back.

Return

DataResult with the result of the block operation (T) or error.

Parameters

propagation

Defines transaction behavior (e.g., whether to join existing or create new).

block

Lambda that receives a QueryOperations context for performing operations.