Type parameters
Hierarchy
-
TableDefinition<ReturnType<typeofany>,Indexes> ↳ViewDefinition
Constructors
constructor
• new ViewDefinition<From, Plan, Indexes>(key, expression, limits)
Type parameters
Parameters
Overrides
TableDefinition<ReturnType<typeof v.any>, Indexes>.constructorProperties
isSource
•Readonly isSource: false
Type-only source ownership, preserved by every builder method.
Inherited from
TableDefinition.isSourcevalidator
• validator:VAny<any, "required", string>
Inherited from
TableDefinition.validatorviewFrom
•Readonly viewFrom: From
viewPlan
•Readonly viewPlan: Plan
viewDefinition
•Readonly viewDefinition: SerializedView
Methods
access
▸ access(definition): ViewDefinition<From, Plan, Indexes>
Authorize reads of this complete table or view, without filtering rows or
redacting fields. View inputs must independently permit disclosure.
The query returns null or the existing positive validity result; throwing
refuses access. Declare at most 32 distinct ordinary policy input tables.
Parameters
Returns
ViewDefinition<From, Plan, Indexes>
Inherited from
TableDefinition.accessretain
▸ retain(options): ViewDefinition<From, Plan, Indexes>
Keep derived data in retained custody. A write into this table is not a
release: the engine retains the writing transaction’s source read
obligations for every custody container the row is in, and every later
read of a row in that container must satisfy them under current source
policy.
by names the containers: _id or a top-level string field that begins
a declared index, or several of them (_id first), one container per
named field. keys: "registered" declares that the containers are
identities this component creates: a row may only enter a container
whose name is the identity of a row inserted into a registered table
keyed by _id, or that a transaction which read nothing wrote first.
Reads confined to one container then carry that container alone, and
an unregistered name reveals nothing. The default, keys: "derived",
allows a key taken from protected data, with one container field, and
decides the absence of a key by every write the table ever received.
Removing or rekeying custody requires a migration.
Parameters
Returns
ViewDefinition<From, Plan, Indexes>
Inherited from
TableDefinition.retainaggregate
▸ aggregate(name, options): ViewDefinition<From, Plan, Indexes>
Maintain exact totals of this table per value of one to three top-level
dimensions: a row count and, for each sum field (a required
v.int64()), an exact sum. A measure may also be a grouping dimension
when totals need equality filters on that measure. The engine updates them in the same commit as
every write to the table and rebuilds them from the rows when the
declaration first appears or its shape changes, so application summaries
grouped by these dimensions — over the whole table, or restricted by
equality on declared dimensions — are exact at any size instead of
bounded by one read. A view that only scans this table is answered from
them too, including one with its own .access() rule, which is then
asked the same question as this table’s.
Calendar totals. time: { field: "at", unit: "day" } stores a UTC
bucket instead of each raw instant for that grouping field. Units are
day, Monday-based week and calendar month. Daily records also answer week
and month summaries. Closed-open time ranges must align with the stored
unit; put the time dimension immediately after any equality-pinned
dimensions. Partial boundaries use the bounded ordinary read. Calendar
totals do not provide indexed min/max. Values are milliseconds or exact
UTC strings like 2026-03-02T12:34:56.789Z; null and missing stay distinct.
Costs. Each distinct dimension-value key is one record that every write
to a row in that group reads and rewrites, so concurrent writers of the
same group serialize (one of them retries), exactly like writers of one
row; writers of different existing groups do not. While the totals are
being built from existing rows, writers also conflict with the build step
that advances past their rows, and summaries use the bounded read until
the build completes. One answer reads at most 256 matching groups. An
equality filter on a later dimension is reached by stepping over the
distinct values of the unfiltered dimensions before it, at most 256 of
them, so put the dimensions a scope filters on first. Records are one per
distinct key, the product of the dimensions’ cardinalities at most.
Extremes. A group’s smallest and largest sum value are not stored:
they are read from an ordinary index whose fields are the grouped and
filtered dimensions, in any order, then that field, e.g.
.index("by_status_amount", ["status", "amount"]) for a summary of
amount by status. Two single-row reads per group keep them exact
under inserts, updates and deletes; without such an index a summary’s
min/max are null and it names the index that would serve them.
Visibility. A total covers every row. On a table with .access() it is
served only with visibility: "collectionReaders", and the rule is then
asked about the whole table (or the rows an equality filter pins) with
the aggregated properties. Declare it only for a rule that refuses that
domain to any caller who may not read every row in it — a rule that
decides per object must refuse an unpinned query demand to any caller
without a role covering the whole table, as the access model’s generated
read rules do. A rule that permits every query demand and filters object by
object would leak totals of rows it hides. A group of a single row is
served like any other: under a read rule the answer is fenced at release
by the group records it read, so deleting a counted row restarts it.
Parameters
Returns
ViewDefinition<From, Plan, Indexes>
Inherited from
TableDefinition.aggregategovern
▸ govern(this, definition): ViewDefinition<From, Plan, Indexes>
Check every net change to this locally owned table before commit.
The query observes the complete tentative transaction. Return one result
per change, in order (readAccessResults): null for clock-independent
permission, or { validUntil } for bounded permission; throw to reject the
changes. A bare result or a missing one refuses. This applies to every writer,
including ordinary composed mutations; it is not a mutation wrapper.
The object form confines private reads to declared input tables. Use
basis: "original" to authorize permission changes from the transaction’s
original state; ordinary governing queries retain final-state reads.
Parameters
Returns
ViewDefinition<From, Plan, Indexes>
Inherited from
TableDefinition.governlink
▸ link<Fields>(this, endpoints): ViewDefinition<From, Plan, Indexes>
Declare a binary association on required typed ID fields.
Each bound counts live associations incident on an endpoint. A nonzero
minimum applies to every live row in that endpoint’s declared table.
Endpoints are immutable; ending and restoring a pair preserves its retained
identity. Native identity and commit enforcement are required for admission.
Type parameters
Parameters
Returns
ViewDefinition<From, Plan, Indexes>
Inherited from
TableDefinition.linksource
▸ source<S>(this, handle): TableDefinition<VAny<any, "required", string>, Indexes, {}, {}, true>
Internal until native source admission is connected.
Type parameters
Parameters
Returns
TableDefinition<VAny<any, "required", string>, Indexes, {}, {}, true>
Inherited from
TableDefinition.sourceindexes
▸ ** indexes**(): {indexDescriptor: string ; fields: string[] }[]
This API is experimental: it may change or disappear.
Returns indexes defined on this table.
Intended for the advanced use cases of dynamically deciding which index to use for a query.
If you think you need this, please chime in on ths issue in the Bijection JS GitHub repo.
Returns
{indexDescriptor: string ; fields: string[] }[]
Inherited from
TableDefinition.[ indexes](server.TableDefinition.md# indexes)self
▸Protected self(): TableDefinition<VAny<any, "required", string>, Indexes, {}, {}, false>
Work around for https://github.com/microsoft/TypeScript/issues/57035
Returns
TableDefinition<VAny<any, "required", string>, Indexes, {}, {}, false>
Inherited from
TableDefinition.selfindex
▸ index<IndexName, FirstFieldPath, RestFieldPaths>(name, config): ViewDefinition<From, Plan, Expand<Indexes & Record<IndexName, [FirstFieldPath, …RestFieldPaths[], "_creationTime"]>>>
Declare an ordinary index over the inferred output fields.
Field existence is checked against the complete schema during admission.
Type parameters
Parameters
Returns
ViewDefinition<From, Plan, Expand<Indexes & Record<IndexName, [FirstFieldPath, …RestFieldPaths[], "_creationTime"]>>>
Overrides
TableDefinition.index ▸ index<IndexName, FirstFieldPath, RestFieldPaths>(name, config): never
Define an index on this table.
To learn about indexes, see Defining Indexes.
Type parameters
Parameters
Returns
never
A TableDefinition with this index included.
Overrides
TableDefinition.indexsearchIndex
▸ searchIndex(..._args): never
Define a search index on this table.
To learn about search indexes, see Search.
Parameters
Returns
never
A TableDefinition with this search index included.
Overrides
TableDefinition.searchIndexvectorIndex
▸ vectorIndex(..._args): never
Define a vector index on this table.
To learn about vector indexes, see Vector Search.
Parameters
Returns
never
A TableDefinition with this vector index included.
Overrides
TableDefinition.vectorIndexstaged
▸ staged(..._args): never
Parameters
Returns
never
Overrides
TableDefinition.stagedmaterialize
▸ materialize():ViewDefinition<From, Plan, Indexes>
Returns
ViewDefinition<From, Plan, Indexes>
export
▸ export():Object
Returns
Object