function withTransaction
withTransaction<T>(work: TransactionWork<T>): Promise<T>

Use this rather than a plain batch only when a multi-step write needs logic between steps, such as create → check capacity → finalize, where a zero-row guard must abort and undo everything.

Concurrent calls serialise on the shared connection. A retry re-runs work on a fresh transaction, so work must be safe to run twice.

Cache invalidations fire once the commit succeeds.

Type Parameters

Parameters

work: TransactionWork<T>

Return Type

Promise<T>

Usage

import { withTransaction } from "docs/database.ts";