← Back to Stormify Documentation

transaction

suspend fun <R> transaction(block: suspend () -> R): R

Execute block inside a transaction. Commits on success, rolls back on any throwable.

If called from inside another transaction { } on the same SuspendStormify (detected via the current ConnectionElement in the coroutine context), reuses that connection via a savepoint rather than acquiring a new one. While the block runs, convenience operations on the underlying Stormify (CRUD, top-level extensions, lazy-loaders, PagedList, etc.) transparently route through this transaction's connection via ActiveTxRegistry.