Skip to main content
A label family is one label per key: a member per organization, team or customer. A table labelled with a family puts each fact in the frame’s member. There is no member column: the member is part of every key, index and read, taken from the frame. This page follows the teams starter.
bijection/tenants.ts
A family has no fixed size. Each member gets its own capacity when it is registered (ctx.register(tenants), see System tables), so nothing is reserved for members that are not registered. Registration mints the member’s random, opaque tag. A founding runs at the public label and registers the member in its own step. It needs the register right for the family from both the caller and the code: the caller holds it through a role’s register: [tenants] or a class grant the app declares (app(tree, { classes: { signedIn: { register: [tenants] } } })), and the code through the founding mutation’s register: [tenants] (see Found a family member). Set { members: n } only to cap how many are registered at once, charged at the public label. Roles clear every member, and a grant of a role is held under one member (see Grants):
bijection/roles.ts

Register and look up a member

With keyed: true, ctx.register(tenants, { key }) associates a business key with a random member tag. A fresh registration validates the key and refuses Exists if a live member already holds it. Erasing that member frees the key for a fresh registration, which mints a new tag. While its receipt is retained, a retry of the same registration occurrence returns the original tag, even after erasure or reassignment of the key. The receipt ignores the supplied business-key value and carries no information about current membership. This also applies to registrations made without a key. A new occurrence or an absent receipt follows the fresh registration path. If a decision depends on who currently holds a business key, base it on await ctx.get(sys.members({ family: tenants, key })) in the live world. A keyed family declares presence: "public", so whether a key is taken is a public fact. The lookup returns the live member’s fact or null when the key is absent. For a write that depends on the lookup, read it in the same mutation so the decision carries the read dependency.

Declare the table

bijection/tasks.ts
label: tenants.and(other) keeps each fact at its member joined with another label.

Write functions under the member

A function with under: tenants runs under the caller’s member. The caller chooses it with client.under(tenants.of(organization)), and the frame clears it only through a grant of the member. Every read and write then addresses the member’s partition. Here organization is the opaque ID suffix of the member tag returned by registration or lookup.

Another member’s partition

table.of(member) addresses one member’s partition instead of the frame’s. A read through it needs a frame that clears that member. A blind write (put, retract, or insert into a minted table) needs only that the frame’s label flows to the member’s, so a lower frame can write up into a member without reading anything there.
One member’s selection is also a reaction source: on: tasks.of(tenants.of(organization)).changes.

Membership

members({ roles, under: tenants }) from @bijectionhq/library-members is a subtree of membership functions; with under, the functions that issue roles run under one member, and accept runs at the public label.
bijection/team.ts
bijection/app.ts
See Grants for inviting members and granting the first owner.

Erasing a member

ctx.erase(tenants.of(organization)) destroys the member’s unit and makes the facts and values under its label unreadable in every version. See History and lifetime.