Skip to main content

References

A field that names a fact of another table has the type t.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 with ctx.get(customers(invoice.customer)), which answers the fact or null. Read the inverse as a bounded selection:
Use 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:
Enforce participation rules in the mutation that writes the association. 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.