Metakit / API

@doeixd/metakit/relation

Questions asked of the rows of another kind that point at a row (@doeixd/metakit/relation): does any follow row point at this author with me as its follower, how many lines does this order have, what do they sum to.

A relation names the kind of the pointing rows and the field they point by (Follow.followee), and the Schema of a pointing row. An environment holds the rows pointing at a row under that row, at the segment <Follow.followee, as { rows, whole }, where whole says whether these are all of them. Evaluation folds them; Expr.judge folds them where all are held, and with some held answers any once one passes and every once one fails; SQL writes a correlated subquery from a table of relations (Sql.toWhere's relations, Drizzle.toWhere's); the checker and the solver answer Unknown.

A body reads the pointing row through the path it is handed, and may read any slice but the one the row asked about is in: SQL carries no second row into a subquery.

Functions

anyWhether some row pointing at of through relation passes test (exists): false over none.
countHow many rows point at of, or how many of them pass test.
defineDeclare a relation between a parent Schema and a child Schema: foreignKey selects the child's field(s) that point at the parent, and parentKey the parent's…
everyWhether every row pointing at of passes test: true over none, and a null test fails.
makeDeclare a relation: Relation.make('Follow.followee', Follow, { cardinality: 'many' }). Its foreignKey selects field(s) of the pointing row; a relation that…
reduceFold value over the rows pointing at of that pass test using a declared commutative-monoid operation op: returns op's identity over no rows and skips null…
withRowsAttach the rows pointing at row through relation for in-memory evaluation and partial evaluation (whole defaults to true).

Values

maxThe greatest value of the rows pointing at of that pass test: null over none.
minThe least value of the rows pointing at of that pass test: null over none.
sumThe total of value over the rows pointing at of that pass test: 0 over none.

Interfaces

RelationThe rows of one kind pointing at a row of another through one of their fields.
RelationOptionsOptional relational metadata on a Relation.

Types

CardinalityCardinality of a relation from parent to child rows.
KeyFieldsA field of Row, or a non-empty tuple of its fields for a composite key.
KeySelectorPicks the key of Row: child => child.authorId, or child => [child.tenantId, child.roomCode].
OnDeleteReferential action when the parent row is deleted.