function useTransaction
useTransaction<T>(
transaction: TxScope | undefined,
work: TransactionWork<T>,
): Promise<T>

Run work on the caller's open transaction, or open one when there is no caller transaction. Transaction-aware table methods use this so direct calls and larger atomic operations share the same write path.

Type Parameters

Parameters

transaction: TxScope | undefined
work: TransactionWork<T>

Return Type

Promise<T>

Usage

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