transaction
The transaction method stages row mutations and publishes them together when the callback succeeds, unless it explicitly rolls back.
transaction<Result>(callback: (transaction: Transaction) => Result | Promise<Result>): Promise<Result>| Type | Description | |
|---|---|---|
callback | (transaction: Transaction) => Result | Promise<Result> | |
| returns | Promise<Result> |
Transaction calls on this Client queue in order. Do not await another transaction on this Client inside the callback; pass its Transaction to helpers instead. Use that object for all SQL in the callback and prepare handles beforehand. Other Clients for the same OPFS name wait for the whole callback to finish. Do not await work on those Clients from inside this callback. An uncaught callback error before commit discards staged work. A caught statement error leaves earlier writes staged unless rollback is called.
There is no cancellation or timeout option. Promise.race only stops waiting, and queued work can still commit. Rejection during commit can leave its outcome uncertain; see the recovery guide before replaying a failed write.
Since
v0.0.5