IF Commons GitHub

sql/extensions/operations/tx

Written to: 2 requirements: 2 proved, 0 partly, 0 failing, 0 with no test recorded. 0031-operations FR-003, 0031-operations FR-004

The transaction an operation is given (commons data 0031-operations): typed row operations by the words of table and column names, written by the naming layer for the dialect, that note what was written. Values enter only as literals the dialect writes.

Source: commons/data/sql/extensions/operations/tx.ts

2 of 7 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

AuditEventinterfaceno test imports it
interface AuditEvent

What audit sinks are given: one thing that was done, or tried.

MemberTypeWhat it is
actionstring
outcome"denied" | "failure" | "success"
actorKind"agent" | "device" | "impersonator" | "machine" | "system" | "user"
actor?string
tenant?string
targetConcept?string
targetKey?string
sessionKey?string
reason?string
detail?Readonly<Record<string, unknown>>
AuditSinkinterface
interface AuditSink

Writes the audit trail; the identity model's is in sql/extensions/operations/identity.

MemberTypeWhat it is
tablestringThe table the trail is kept in, by the words of its name: a write to it is not a write outside a contract.
record(tx: Tx, event: AuditEvent, context: Context) => Promise<string>

Imported by 6 tests of the run (6 passed, 0 failed): the library's results

Rowtype
type Row = Readonly<Record<string, unknown>>;

A row as an operation reads and writes it: column names to values.

Imported by 11 tests of the run (11 passed, 0 failed): the library's results

Testtypeno test imports it
type Test = Cell | { readonly gt?: Cell; readonly ge?: Cell; readonly lt?: Cell; readonly le?: Cell; readonly ne?: Cell };

A condition on a column: equal to a value (null meaning is null), or compared.

Txinterfaceno test imports it
interface Tx extends TxRefs

A transaction.

MemberTypeWhat it is
insert(table: string, values: Readonly<Record<string, Cell>>) => Promise<void>
update(table: string, set: Readonly<Record<string, Cell>>, where: Readonly<Record<string, Test>>) => Promise<number>The number of rows changed.
remove(table: string, where: Readonly<Record<string, Test>>) => Promise<number>The number of rows removed.
select(table: string, options?: { readonly where?: Readonly<Record<string, Test>> | undefined; readonly columns?: readonly string[] | undefined; readonly orderBy?: readonly (readonly [string, "asc" | "desc"])[] | undefined; readonly limit?: number | undefined; } | undefined) => Promise<Readonly<Record<string, unknown>>[]>Rows, each keyed by the columns asked for (as asked), or by every column in lower camel case.
count(table: string, where?: Readonly<Record<string, Test>> | undefined) => Promise<number>
query(build: (refs: TxRefs) => string) => Promise<Readonly<Record<string, unknown>>[]>A read written by the caller from the names, whose columns are the aliases it gives.
audit(event: AuditEvent) => Promise<string>Records an event in the audit trail, in this transaction; gives its hash.
table(name: string) => string
col(table: string, key: string) => stringA column of a table, written and quoted, by the words of its name or the key of the relationship it holds.
lit(value: Cell) => string
code(value: string) => stringA code of a code list as the database holds it, written by the naming layer from the words of the code.
TxRefsinterfaceno test imports it
interface TxRefs

The names a raw query asks for.

MemberTypeWhat it is
table(name: string) => string
col(table: string, key: string) => stringA column of a table, written and quoted, by the words of its name or the key of the relationship it holds.
lit(value: Cell) => string
code(value: string) => stringA code of a code list as the database holds it, written by the naming layer from the words of the code.
Wheretypeno test imports it
type Where = Readonly<Record<string, Test>>;

The conditions that pick rows in an operation: a test for each column named.

Titles, headings, exports, tables, columns and requirements. Esc closes.