function writeRowInTransaction
writeRowInTransaction<State = never>(
statement: InStatement,
existingId: number | null,
persist: (
tx: TxScope,
id: number,
state: State | null,
) => Promise<void>
,
readState?: TransactionStateReader<State>,
): Promise<number>

Write one row statement in a fresh write transaction and run persist (the coupled join-table writes) on the same tx, so the row and its side writes commit or roll back together. On update, the optional readState step runs before the statement — it reads the state that reaches persist and may refuse the write by throwing; creates skip it. Returns the row id.

Type Parameters

State = never

Parameters

statement: InStatement
existingId: number | null
persist: (
tx: TxScope,
id: number,
state: State | null,
) => Promise<void>
optional
readState: TransactionStateReader<State>

Return Type

Promise<number>

Usage

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