writeTransaction

abstract suspend fun <R> writeTransaction(callback: ThrowableTransactionCallback<R>): R

Opens a read-write transaction.

This takes a global lock, ensuring that only one write transaction can execute against the database at a time, even across separate database instances for the same file.

Statements within the transaction must be done on the provided PowerSyncTransaction - attempting statements on the database instance will error cause a dead-lock.

Return

The result of the callback.

Parameters

callback

The callback to execute within the transaction.

Throws

If a database error occurs.

If the operation is cancelled.