Metakit / API

@doeixd/metakit/sql

SQL text for Postgres and SQLite (@doeixd/metakit/sql): a Schema's rules as a CHECK, a boolean expression as a WHERE predicate with its parameters, and a transition as a guarded UPDATE.

The lowering itself is sqlLowering.ts, which @doeixd/metakit/drizzle renders too; this module renders its pieces as text.

Functions

lowerNodeLower node, reading a path under rowPrefix as a column. The root path (Path.root()) reads every path as a column.
relatedSubqueryA correlated subquery over the related rows, in a renderer's form of SQL: from is their table, matches says a row points at the row asked of, and an element…
targetA SQL target for Language.readiness and Tooling.explain that also asks of a transition what toUpdate asks, through its own lowering, with every path read as…
toCheckEvery rule of schema as a SQL CHECK (...) clause. The check fails where a rule is unknown of a null, as the Schema refuses that value. Literals are written…
toUpdateA Transition and one input as a guarded, parameterized SQL UPDATE of table: it writes only the rows the guard holds of and whose step does not refuse, each…
toValueAn Expr as a parameterized SQL value, for a SELECT list: null is NULL, a boolean stays apart from null, and a refusal is NULL or an error the database…
toWhereA boolean Expr as a parameterized SQL WHERE predicate. Only true keeps a row. Where an enclosing operator could read refusal as a value, lowering tests for…

Values

sqlOps
SqlPieceOne piece of lowered SQL.

Classes

Interfaces

ClaimOptionsWhat lets toUpdate write the result of a custom operation: its claims.total, read only under a rewrite policy, as every reader of a claim reads it…
RelationTableWhere the rows related to a row through a relation are: their table, the column of it that holds the id of the row they point at, and the column of the…
SqlContext
SqlFragmentA statement or a term of one, and the values it binds in the order its placeholders take them.
SqlOptions

Types

ColumnNameHow a path under the row becomes SQL for its column; the default quotes its segments joined by _.
RelatedFoldThe folds SQL asks of related rows: the others answer in an order, or with a list.
RelationTablesThe table of each relation a Rows node over related rows names, as [relation, table] pairs. A relation listed twice throws.
SqlLowered SQL: its pieces in the order they are written.
SqlDialect
SqlLowerer
SqlParamA value a statement binds, as the driver of D takes it: on SQLite a number or text (a boolean is bound as 1 or 0, a list as JSON text read through json(?)),…