> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Object sets

> Filter objects, traverse declared links, and page or aggregate a bounded result.

Publish an object-set query when readers need to compose a finite set of
view routes. The root's equality fields match a prefix of one `serve.find`
order. Each link carries a per-parent bound. The set reads under the
root view's audience. Each called view and link applies its own admission.

```ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { objectSet, ontology } from "@bijectionhq/library-views";

export const customerOrders = objectSet(Customer, {
  allow: [salesRep],
  roots: { where: ["region"], max: 8 },
  through: { orders: { maxPerRoot: 8, where: ["status"], sums: ["amount"] } },
  page: { max: 32 },
});

export const catalog = ontology({ customers: Customer }, {
  allow: [salesRep],
  sets: { customerOrders },
});
```

Place `customerOrders` in your app under `sets` and the catalog at `ontology`.
A link's `through` may name a further declared link. Up to three successive
links and 256 root and traversed rows fit in a logical plan. A root or a
link that exceeds a declared bound refuses with `Limit`. A view's exact
materialized-index overlay or protected carrier can examine up to its own
256 candidates to establish a stage. The host still applies the existing
read work ceilings and member scope to those physical reads.

```ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { objects } from "@bijectionhq/library-views";

const regionalOrders = objects(client, api.sets.customerOrders);
const open = regionalOrders.where({ region: "EU" }).pivotTo("orders").where({ status: "open" });
const other = regionalOrders.where({ region: "US" }).pivotTo("orders").where({ status: "open" });
const first = await open.page({ size: 20 }).pick("status", "amount").read();
const total = await open.union(other).aggregate({ count: true, sum: ["amount"] });

if (first.ok && first.value.kind === "page" && first.value.next !== null) {
  await open.page({ size: 20, after: first.value }).pick("status", "amount").read();
}
```

`union`, `intersect`, and `subtract` combine operands from the same published
set that reach the same view. Further expressions use the filters, measures,
and links published on both operands. A target key contributes once. Sums are exact
for integer and decimal measures and answer null when every value is null
or the result is empty.

A page carries its `world`, `version`, and continuation. Reuse its plan,
projection and size. The SDK's `after` selects the preceding page's world.
For raw client calls, select the returned `world` explicitly. Each page is
authorized at entry, and the cursor also matches the caller and frame. A
branch continuation requires the same visible ordering and read version.
Pages order by target key by default. A route may declare
`order: { field, direction }` and still uses the key as a tie-breaker.

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
bijection describe ontology --set customerOrders
bijection query sets.customerOrders 'answer:={"kind":"describe"}'
bijection query sets.customerOrders \
  'plan:={"where":{"region":"EU"},"steps":[{"link":"orders","where":{"status":"open"}}]}' \
  'answer:={"kind":"page","size":20}'
```

The set reads landed answers for an external link. A terminal page supplies
complete membership for that observed selector. An attested source can
supply additional pages at the same cut. A PostgreSQL read declared with
`snapshot: true` serves all its pages from one bounded observation. An exact
set that needs a continuation from independently acquired pages answers
`kind: "unavailable"`, `state: "incomplete"`. A ready result
reports the observations it used and their available cut witnesses. Multiple
roots can reach different observed source instants. Landed sums describe
the selected values in this Bijection frame.

An unasked or refused external page can carry the caller's authorized
refresh coordinates. Send that mutation explicitly and then run the object
set again. A set submits no requests. To read a retained copy, publish
its served view and the linked routes that cover the copied facts.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.