function writeRowInTransaction
writeRowInTransaction(
statement: InStatement,
existingId: number | null,
persist: (
tx: TxScope,
id: number,
) => Promise<void>
,
): 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. Returns the row id — existingId on update, or the INSERT's lastInsertRowid on create (existingId null). Shared by the REST resource (HTML forms) and CRUD API write paths.

Parameters

statement: InStatement
existingId: number | null
persist: (
tx: TxScope,
id: number,
) => Promise<void>

Return Type

Promise<number>

Usage

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