- A view computes a keyed, read-only collection from your tables. Each view defines an object type, and each row is one identified object.
- A link type is an ordinary table whose rows associate two records, with the cardinality you declare enforced on every write.
ctx.db calls you already use in queries.
Here is a view that summarizes each customer’s orders:
bijection/schema.ts
bijection/customers.ts
summary for that customer receives the new count, just as
with any other query.
Views
A view is declared withdefineView({ key, expression }). The expression is
built with the q builder from a fixed set of relational operators: scan,
filter, projection, equality joins and grouping. Bijection checks the whole
definition when you deploy, infers the output type, and evaluates it for you.
You never write to a view: its rows change when its inputs change.
A view is virtual by default, which means it’s evaluated when it’s read.
Add .materialize() and Bijection stores its output instead, keeping it current
in the same transaction as every write to its inputs. Both forms return the same
results.
Links
A link type is a table with two typed ID fields, its endpoints, and a.link(...) declaration that states how many links each record may take part
in:
bijection/schema.ts
Tables, views and link types
Defining views
Declare a view with a key and a
q expression.Joins and aggregates
Combine tables with equality joins and group with counts and sums.
Reading views
Read views from queries, with indexes, pagination and reactivity.
Materialized views
Store a view’s output and keep it current on every write.
Link types
Declare associations between records with enforced cardinality.