References
A field that names a fact of another table has the typet.key(table).
Declare an index that starts with the field when you need the inverse read.
t.key(() => table) names a table declared later in the module, and
t.key.self names a fact of the same table.
Following references
Read the target withctx.get(customers(invoice.customer)), which answers the
fact or null. Read the inverse as a bounded selection:
ctx.page(invoices.where({ customer }).by("placed"), { size, cursor })
to hand the client one window and its next cursor. A selection no declared
index serves is refused with the index to add.
Associations
Use a separate table when an association has its own fields or several facts per endpoint. Key it by both endpoints so a pair is a point, and index the other order for the reverse read:ctx.insert(members({ team, person }), fact) refuses Exists for a pair
already present. A guard on act.write(members, { transition: "create" })
covers every creation of a membership. See Reading for paging the inverse.