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
any | Whether some row pointing at of through relation passes test (exists): false over none. |
count | How many rows point at of, or how many of them pass test. |
define | Declare 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… |
every | Whether every row pointing at of passes test: true over none, and a null test fails. |
make | Declare a relation: Relation.make('Follow.followee', Follow, { cardinality: 'many' }). Its foreignKey selects field(s) of the pointing row; a relation that… |
reduce | Fold 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… |
withRows | Attach the rows pointing at row through relation for in-memory evaluation and partial evaluation (whole defaults to true). |
Values
max | The greatest value of the rows pointing at of that pass test: null over none. |
min | The least value of the rows pointing at of that pass test: null over none. |
sum | The total of value over the rows pointing at of that pass test: 0 over none. |
Interfaces
Relation | The rows of one kind pointing at a row of another through one of their fields. |
RelationOptions | Optional relational metadata on a Relation. |
Types
Cardinality | Cardinality of a relation from parent to child rows. |
KeyFields | A field of Row, or a non-empty tuple of its fields for a composite key. |
KeySelector | Picks the key of Row: child => child.authorId, or child => [child.tenantId, child.roomCode]. |
OnDelete | Referential action when the parent row is deleted. |