pub struct AggregateModel {
pub aggregate: Ident,
pub vis: Visibility,
pub krate: Path,
pub krate_spelled: Option<LitStr>,
pub upstream: Path,
pub groups: Vec<Grouped>,
pub measures: Vec<Measured>,
pub triggers: TokenStream,
pub stores: TokenStream,
pub graphql: Option<TokenStream>,
}Expand description
A validated aggregate declaration.
PLAIN, for the reason every model in this crate has plain fields: the derive today and a manifest front end later reach the same emitter.
§Three fields are TOKENS, and the passthrough is the journal’s law rather than laziness
triggers, stores and graphql are the
words this declaration shares with the RECORD grammar, and they are carried UNINTERPRETED. The
aggregate’s storage IS a record’s — the emission mints the (group…, measure…) row shape and
hands it to the record pass, which is #[ingraph::journal]’s pattern verbatim — so reading a
database block, a table = "…" or a poll(…) entry here would be a SECOND authority for one
vocabulary, and two authorities for one vocabulary is how the two of them drift.
What the front end knows about them is only which WORDS start one, which it needs anyway to refuse a declaration that names no clock. Their teeth arrive with the record pass, at the same expansion that spends them.
Fields§
§aggregate: IdentThe declaration’s own name.
vis: VisibilityThe declaration’s visibility, carried for the types the emission mints beside it.
krate: PathWhere ingraph lives, as crate = "…" named it or ::ingraph where it named none.
krate_spelled: Option<LitStr>The same, AS WRITTEN — the literal the record grammar is handed back when the emission mounts this declaration as a record.
Both halves are carried for #[ingraph::journal]’s stated reason: one authority for the path,
and no round trip through a rendered path that could differ from the one that was written.
upstream: Pathupstream(node = "…") — the ONE node whose rows are folded.
The edge and NOTHING ELSE, which is where this word differs from the derived indexes’ spelling
of it: theirs carries the projection too, because a document is one upstream message and every
field of it is read out of that message. Here only the GROUP columns are read out of a row —
a measure’s column is FOLDED into being — so a projection written inside upstream(…) would
claim a totality this kind does not have, and is refused pointing at GROUP.
groups: Vec<Grouped>The GROUP projection, in the order the declaration wrote its fields.
Never empty: a declaration with no group is refused before a model is built. The key this kind mints IS these columns, which is why a groupless aggregate has no shape here — it would be one keyless row, and the record family stores rows by key.
measures: Vec<Measured>The MEASURE columns, in the order the declaration wrote its fields. Never empty.
triggers: TokenStreamEvery poll(…) entry as written, comma-joined, ready to be handed to the record grammar.
Never empty: an aggregate recomputes ON A TRIGGER, so a declaration naming no clock would never run and its table would answer nothing, forever.
stores: TokenStreamThe store words and their two common entries as written, comma-joined — sqlite,
postgres(schema = "…"), table = "…", rename = "…".
May be EMPTY, and the emptiness is answered by the record pass rather than here: a thing that holds rows names where they land is the record grammar’s sentence, and this grammar knowing only which words START a store has nothing of its own to add to it.
graphql: Option<TokenStream>graphql(…) as written, or None where the declaration named no backend.
Implementations§
Source§impl AggregateModel
impl AggregateModel
Sourcepub fn columns(&self) -> impl Iterator<Item = &Ident>
pub fn columns(&self) -> impl Iterator<Item = &Ident>
The declaration’s columns in ROW ORDER — every group column, then every measure.
The row shape the emission mints is these columns in this order, so the walk is the model’s rather than each reader’s: two readers ordering one row shape differently is a table whose columns depend on who asked. Groups lead because they are the KEY, and a key is a row’s first columns everywhere else in this framework.