readTransaction

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

Opens a read-only transaction.

Statements within the transaction must be done on the provided PowerSyncTransaction - executing statements on the database level will be executed on separate connections.

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.