withSuspendTransaction

suspend fun <T> Transaction.withSuspendTransaction(context: CoroutineContext? = null, statement: suspend Transaction.() -> T): T

Calls the specified suspending statement, suspends until it completes, and returns the result.

The resulting TransactionScope is derived from the current CoroutineContext if the latter already holds this Transaction; otherwise, a new scope is created using this Transaction and a given coroutine context.

Samples

org.jetbrains.exposed.sql.tests.shared.CoroutineTests.suspendedTx