function transaction
transaction<T>(fn: () => T): T

Runs fn in a transaction, so its writes commit together, in one commit rather than one each, and a throw rolls them all back and rethrows. A call inside another joins the outer transaction. fn must be synchronous: an await would commit before the rest of it runs.

Type Parameters

Parameters

fn: () => T

Return Type

Usage

import { transaction } from "api/db/connection.ts";