Transactor
-
Cmn
interface Transactor : PooledConnection
A PooledConnection that can perform transactions.
Summary
Nested types |
|---|
|
Transaction types. |
Public functions |
||
|---|---|---|
suspend Boolean |
Returns true if this connection has an active transaction, otherwise false. |
Cmn
|
suspend R |
<R : Any?> withTransaction(Begins a transaction and runs the |
Cmn
|
Extension functions |
||
|---|---|---|
suspend R |
<R : Any?> Transactor.deferredTransaction(block: suspend TransactionScope<R>.() -> R)Performs a |
Cmn
|
suspend R |
<R : Any?> Transactor.exclusiveTransaction(block: suspend TransactionScope<R>.() -> R)Performs a |
Cmn
|
suspend R |
<R : Any?> Transactor.immediateTransaction(block: suspend TransactionScope<R>.() -> R)Performs a |
Cmn
|
Inherited functions |
|||
|---|---|---|---|
|
Public functions
inTransaction
suspend fun inTransaction(): Boolean
Returns true if this connection has an active transaction, otherwise false.
withTransaction
suspend fun <R : Any?> withTransaction(
type: Transactor.SQLiteTransactionType,
block: suspend TransactionScope<R>.() -> R
): R
Begins a transaction and runs the block within the transaction. If block fails to complete normally i.e., an exception is thrown, or TransactionScope.rollback is invoked then the transaction will be rollback, otherwise it is committed.
If inTransaction returns true and this function is invoked it is the equivalent of starting a nested transaction as if TransactionScope.withNestedTransaction was invoked and the type of the transaction will be ignored since its type will be inherited from the parent transaction.
See also Transaction
| Parameters | |
|---|---|
type: Transactor.SQLiteTransactionType |
The type of transaction to begin. |
block: suspend TransactionScope<R>.() -> R |
The code that will execute within the transaction. |
Extension functions
deferredTransaction
suspend fun <R : Any?> Transactor.deferredTransaction(block: suspend TransactionScope<R>.() -> R): R
Performs a SQLiteTransactionType.DEFERRED within the block.
exclusiveTransaction
suspend fun <R : Any?> Transactor.exclusiveTransaction(block: suspend TransactionScope<R>.() -> R): R
Performs a SQLiteTransactionType.EXCLUSIVE within the block.
immediateTransaction
suspend fun <R : Any?> Transactor.immediateTransaction(block: suspend TransactionScope<R>.() -> R): R
Performs a SQLiteTransactionType.IMMEDIATE within the block.