> ## 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.

# Class: VirtualTableDefinition<Fields>

> A remote-only OLAP relation.

[server](/api/modules/server).VirtualTableDefinition

A remote-only OLAP relation. It has no local documents, indexes, or sync job.
Configure its integration connection through deployment administration.

## Type parameters

| Name | Type |
| :- | :- |
| `Fields` | extends [`PropertyValidators`](/api/modules/values#propertyvalidators) |

## Hierarchy

* [`TableDefinition`](/api/classes/server.TableDefinition)\<`ReturnType`\<typeof `object`>>

  ↳ **`VirtualTableDefinition`**

## Constructors

### constructor

• **new VirtualTableDefinition**\<`Fields`>(`collection`)

#### Type parameters

| Name | Type |
| :- | :- |
| `Fields` | extends [`PropertyValidators`](/api/modules/values#propertyvalidators) |

#### Parameters

| Name | Type |
| :- | :- |
| `collection` | [`SourceHandle`](/api/modules/server#sourcehandle)\<`Fields`> |

#### Overrides

TableDefinition\&lt;ReturnType\&lt;typeof v.object\&lt;Fields\&gt;\&gt;\&gt;.constructor

## Properties

### isSource

• `Readonly` **isSource**: `false`

Type-only source ownership, preserved by every builder method.

#### Inherited from

[TableDefinition](/api/classes/server.TableDefinition).[isSource](/api/classes/server.TableDefinition#issource)

***

### validator

• **validator**: [`VObject`](/api/classes/values.VObject)\<[`Expand`](/api/modules/server#expand)\<\{ \[Property in string | number | symbol]?: Exclude\<Infer\<Fields\[Property]>, undefined> } & \{ \[Property in string | number | symbol]: Infer\<Fields\[Property]> }>, `Fields`, `"required"`, \{ \[Property in string | number | symbol]: Property | \`$\{Property & string}.$\{Fields\[Property]\["fieldPaths"]}\` }\[keyof `Fields`] & `string`>

#### Inherited from

[TableDefinition](/api/classes/server.TableDefinition).[validator](/api/classes/server.TableDefinition#validator)

***

### virtualTableDefinition

• `Readonly` **virtualTableDefinition**: `true`

## Methods

### access

▸ **access**(`definition`): [`VirtualTableDefinition`](/api/classes/server.VirtualTableDefinition)\<`Fields`>

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

| Name | Type |
| :- | :- |
| `definition` | [`ReadAccess`](/api/modules/server#readaccess) |

#### Returns

[`VirtualTableDefinition`](/api/classes/server.VirtualTableDefinition)\<`Fields`>

#### Inherited from

[TableDefinition](/api/classes/server.TableDefinition).[access](/api/classes/server.TableDefinition#access)

***

### resourceRequests

▸ **resourceRequests**(`options`): [`VirtualTableDefinition`](/api/classes/server.VirtualTableDefinition)\<`Fields`>

Declare the native access-request writer. Attach the access model's
read and original-basis write rules; ordinary mutations cannot change
this table. Approval inserts the requested grant and schedules expiry
in the decision's transaction.

#### Parameters

| Name | Type |
| :- | :- |
| `options` | `Object` |
| `options.grants` | `string` |
| `options.expire` | [`FunctionReference`](/api/modules/server#functionreference)\<`"mutation"`, `"internal"`, \{ `id`: [`GenericId`](/api/modules/values#genericid)\<`string`>  }> |

#### Returns

[`VirtualTableDefinition`](/api/classes/server.VirtualTableDefinition)\<`Fields`>

#### Inherited from

[TableDefinition](/api/classes/server.TableDefinition).[resourceRequests](/api/classes/server.TableDefinition#resourcerequests)

***

### retain

▸ **retain**(`options`): [`VirtualTableDefinition`](/api/classes/server.VirtualTableDefinition)\<`Fields`>

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

| Name | Type |
| :- | :- |
| `options` | `Object` |
| `options.by` | `string` \| `string`\[] |
| `options.keys?` | `"registered"` \| `"derived"` |

#### Returns

[`VirtualTableDefinition`](/api/classes/server.VirtualTableDefinition)\<`Fields`>

#### Inherited from

[TableDefinition](/api/classes/server.TableDefinition).[retain](/api/classes/server.TableDefinition#retain)

***

### aggregate

▸ **aggregate**(`name`, `options`): [`VirtualTableDefinition`](/api/classes/server.VirtualTableDefinition)\<`Fields`>

Maintain exact totals of this table per value of one to four 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. A write adds its change to each group it touches as a new record
and reads none, so concurrent writers of one group do not conflict; the
engine folds a group's records into one shortly after. While the totals
are being built from existing rows, a writer conflicts only with the
build step counting its row and once with the step that completes the
build, and summaries use the bounded read until the build completes. One
answer reads at most 256 matching non-empty groups and 4,096 unfolded
records (`compacting` past that, until the engine catches up); a view's
grouped lookup reads at most 64 before it evaluates the group from its
rows, within the view's limits. 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. Once folded, records are one per
distinct key, the product of the dimensions' cardinalities at most. A sum
past the int64 range refuses the summaries that serve it (`overflow`)
until the rows fit again; writes are never refused.

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 and `target.covers: true`: no row it counts is
presented on its own. Declare it only for a rule that decides such a
request as every row in its domain, as the access model's generated read
rules do. A rule that ignores `covers` and permits a range because it
decides the range's rows one by one 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 terms it read, so deleting a
counted row restarts it.

#### Parameters

| Name | Type | Description |
| :- | :- | :- |
| `name` | `string` | - |
| `options` | `Object` | - |
| `options.by` | `string`\[] | - |
| `options.sum?` | `string`\[] | - |
| `options.decimal?` | `Record`\<`string`, `number`> | Required decimal string fields and their exact fixed scales (0–38). |
| `options.time?` | `Object` | - |
| `options.time.field` | `string` | - |
| `options.time.unit` | `"day"` \| `"week"` \| `"month"` | - |
| `options.visibility?` | `"collectionReaders"` | - |

#### Returns

[`VirtualTableDefinition`](/api/classes/server.VirtualTableDefinition)\<`Fields`>

#### Inherited from

[TableDefinition](/api/classes/server.TableDefinition).[aggregate](/api/classes/server.TableDefinition#aggregate)

***

### govern

▸ **govern**(`this`, `definition`): [`VirtualTableDefinition`](/api/classes/server.VirtualTableDefinition)\<`Fields`>

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

| Name | Type |
| :- | :- |
| `this` | [`VirtualTableDefinition`](/api/classes/server.VirtualTableDefinition)\<`Fields`> |
| `definition` | `GoverningDefinition`\<[`Expand`](/api/modules/server#expand)\<[`SystemFields`](/api/modules/server#systemfields) & [`Expand`](/api/modules/server#expand)\<\{ \[Property in string \| number \| symbol]?: Exclude\<Infer\<Fields\[Property]>, undefined> } & \{ \[Property in string \| number \| symbol]: Infer\<Fields\[Property]> }>> & \{ `_id`: [`GenericId`](/api/modules/values#genericid)\<`string`>  }> |

#### Returns

[`VirtualTableDefinition`](/api/classes/server.VirtualTableDefinition)\<`Fields`>

#### Inherited from

[TableDefinition](/api/classes/server.TableDefinition).[govern](/api/classes/server.TableDefinition#govern)

***

### link

▸ **link**\<`Fields`>(`this`, `endpoints`): [`VirtualTableDefinition`](/api/classes/server.VirtualTableDefinition)\<`Fields`>

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.
One endpoint may name `_storage` when its minimum is zero and the relationship
declares read access and a governing rule. Such attachments require sealed
content and preserve the file's existing source restrictions.

#### Type parameters

| Name | Type |
| :- | :- |
| `Fields` | extends `string` |

#### Parameters

| Name | Type |
| :- | :- |
| `this` | `LinkableTable`\<[`VObject`](/api/classes/values.VObject)\<[`Expand`](/api/modules/server#expand)\<\{ \[Property in string \| number \| symbol]?: Exclude\<Infer\<Fields\[Property]>, undefined> } & \{ \[Property in string \| number \| symbol]: Infer\<Fields\[Property]> }>, `Fields`, `"required"`, \{ \[Property in string \| number \| symbol]: Property \| \`$\{Property & string}.$\{Fields\[Property]\["fieldPaths"]}\` }\[keyof `Fields`] & `string`>, `false`, [`VirtualTableDefinition`](/api/classes/server.VirtualTableDefinition)\<`Fields`>> |
| `endpoints` | `Record`\<`Fields`, readonly \[`number`, `number` \| `"many"`]> |

#### Returns

[`VirtualTableDefinition`](/api/classes/server.VirtualTableDefinition)\<`Fields`>

#### Inherited from

[TableDefinition](/api/classes/server.TableDefinition).[link](/api/classes/server.TableDefinition#link)

***

### source

▸ **source**\<`S`>(`this`, `handle`): [`TableDefinition`](/api/classes/server.TableDefinition)\<[`VObject`](/api/classes/values.VObject)\<[`Expand`](/api/modules/server#expand)\<[`Expand`](/api/modules/server#expand)\<\{ \[Property in string | number | symbol]?: Exclude\<Infer\<Fields\[Property]>, undefined> } & \{ \[Property in string | number | symbol]: Infer\<Fields\[Property]> }> & `HostSourceFields`>, [`Expand`](/api/modules/server#expand)\<`Fields` & `HostSourceFieldValidators`>, `"required"`, \{ \[Property in string | number | symbol]: Property | \`$\{Property & string}.$\{Expand\<Fields & HostSourceFieldValidators>\[Property]\["fieldPaths"]}\` }\[keyof [`Expand`](/api/modules/server#expand)\<`Fields` & `HostSourceFieldValidators`>] & `string`>, \{}, \{}, \{}, `true`>

Internal until native source admission is connected.

#### Type parameters

| Name | Type |
| :- | :- |
| `S` | extends `Record`\<`string`, [`GenericValidator`](/api/modules/values#genericvalidator)> |

#### Parameters

| Name | Type |
| :- | :- |
| `this` | [`VirtualTableDefinition`](/api/classes/server.VirtualTableDefinition)\<`Fields`> |
| `handle` | [`SourceHandle`](/api/modules/server#sourcehandle)\<`S`> & \[[`Expand`](/api/modules/server#expand)\<\{ \[Property in string \| number \| symbol]?: Exclude\<Infer\<Fields\[Property]>, undefined> } & \{ \[Property in string \| number \| symbol]: Infer\<Fields\[Property]> }>] extends \[[`Expand`](/api/modules/server#expand)\<\{ \[Property in string \| number \| symbol]?: Exclude\<Infer\<S\[Property]>, undefined> } & \{ \[Property in string \| number \| symbol]: Infer\<S\[Property]> }>] ? \[[`Expand`](/api/modules/server#expand)\<\{ \[Property in string \| number \| symbol]?: Exclude\<Infer\<S\[Property]>, undefined> } & \{ \[Property in string \| number \| symbol]: Infer\<S\[Property]> }>] extends \[[`Expand`](/api/modules/server#expand)\<\{ \[Property in string \| number \| symbol]?: Exclude\<Infer\<S\[Property]>, undefined> } & \{ \[Property in string \| number \| symbol]: Infer\<S\[Property]> }> & [`Expand`](/api/modules/server#expand)\<\{ \[Property in string \| number \| symbol]?: Exclude\<Infer\<Fields\[Property]>, undefined> } & \{ \[Property in string \| number \| symbol]: Infer\<Fields\[Property]> }>] ? `unknown` : `never` : `never` |

#### Returns

[`TableDefinition`](/api/classes/server.TableDefinition)\<[`VObject`](/api/classes/values.VObject)\<[`Expand`](/api/modules/server#expand)\<[`Expand`](/api/modules/server#expand)\<\{ \[Property in string | number | symbol]?: Exclude\<Infer\<Fields\[Property]>, undefined> } & \{ \[Property in string | number | symbol]: Infer\<Fields\[Property]> }> & `HostSourceFields`>, [`Expand`](/api/modules/server#expand)\<`Fields` & `HostSourceFieldValidators`>, `"required"`, \{ \[Property in string | number | symbol]: Property | \`$\{Property & string}.$\{Expand\<Fields & HostSourceFieldValidators>\[Property]\["fieldPaths"]}\` }\[keyof [`Expand`](/api/modules/server#expand)\<`Fields` & `HostSourceFieldValidators`>] & `string`>, \{}, \{}, \{}, `true`>

#### Inherited from

[TableDefinition](/api/classes/server.TableDefinition).[source](/api/classes/server.TableDefinition#source)

***

### indexes

▸ \*\* 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](/api/classes/server.TableDefinition).\[ indexes]\(server.TableDefinition.md# indexes)

***

### index

▸ **index**\<`IndexName`, `FirstFieldPath`, `RestFieldPaths`>(`name`, `indexConfig`): [`TableDefinition`](/api/classes/server.TableDefinition)\<[`VObject`](/api/classes/values.VObject)\<[`Expand`](/api/modules/server#expand)\<\{ \[Property in string | number | symbol]?: Exclude\<Infer\<Fields\[Property]>, undefined> } & \{ \[Property in string | number | symbol]: Infer\<Fields\[Property]> }>, `Fields`, `"required"`, \{ \[Property in string | number | symbol]: Property | \`$\{Property & string}.$\{Fields\[Property]\["fieldPaths"]}\` }\[keyof `Fields`] & `string`>, [`Expand`](/api/modules/server#expand)\<`Record`\<`IndexName`, \[`FirstFieldPath`, ...RestFieldPaths\[], `"_creationTime"`]>>, \{}, \{}, `false`>

Define an index on this table.

Indexes speed up queries by allowing efficient lookups on specific fields.
Use `.withIndex()` in your queries to leverage them.

Index fields must be queried in the same order they are defined. If you
need to query by `field2` then `field1`, create a separate index with
that field order.

**`Example`**

```ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
defineTable({
  userId: v.id("users"),
  status: v.string(),
  updatedAt: v.number(),
})
  // Name indexes after their fields:
  .index("by_userId", ["userId"])
  .index("by_status_updatedAt", ["status", "updatedAt"])
```

**Best practice:** Always include all index fields in the index name
(e.g., `"by_field1_and_field2"`).

**`See`**

[https://docs.bijection.com/database/reading-data/indexes](/database/reading-data/indexes/indexes)

#### Type parameters

| Name | Type |
| :- | :- |
| `IndexName` | extends `string` |
| `FirstFieldPath` | extends `string` |
| `RestFieldPaths` | extends `ExtractFieldPaths`\<[`VObject`](/api/classes/values.VObject)\<[`Expand`](/api/modules/server#expand)\<\{ \[Property in string \| number \| symbol]?: Exclude\<Infer\<Fields\[Property]>, undefined> } & \{ \[Property in string \| number \| symbol]: Infer\<Fields\[Property]> }>, `Fields`, `"required"`, \{ \[Property in string \| number \| symbol]: Property \| \`$\{Property & string}.$\{Fields\[Property]\["fieldPaths"]}\` }\[keyof `Fields`] & `string`>>\[] |

#### Parameters

| Name | Type | Description |
| :- | :- | :- |
| `name` | `IndexName` | The name of the index. |
| `indexConfig` | `Object` | The index configuration object. |
| `indexConfig.fields` | \[`FirstFieldPath`, ...RestFieldPaths\[]] | The fields to index, in order. Must specify at least one field. |
| `indexConfig.staged?` | `false` | Whether the index should be staged. For large tables, index backfill can be slow. Staging an index allows you to push the schema and enable the index later. If `staged` is `true`, the index will be staged and will not be enabled until the staged flag is removed. Staged indexes do not block push completion. Staged indexes cannot be used in queries. |

#### Returns

[`TableDefinition`](/api/classes/server.TableDefinition)\<[`VObject`](/api/classes/values.VObject)\<[`Expand`](/api/modules/server#expand)\<\{ \[Property in string | number | symbol]?: Exclude\<Infer\<Fields\[Property]>, undefined> } & \{ \[Property in string | number | symbol]: Infer\<Fields\[Property]> }>, `Fields`, `"required"`, \{ \[Property in string | number | symbol]: Property | \`$\{Property & string}.$\{Fields\[Property]\["fieldPaths"]}\` }\[keyof `Fields`] & `string`>, [`Expand`](/api/modules/server#expand)\<`Record`\<`IndexName`, \[`FirstFieldPath`, ...RestFieldPaths\[], `"_creationTime"`]>>, \{}, \{}, `false`>

A [TableDefinition](/api/classes/server.TableDefinition) with this index included.

#### Inherited from

[TableDefinition](/api/classes/server.TableDefinition).[index](/api/classes/server.TableDefinition#index)

▸ **index**\<`IndexName`, `FirstFieldPath`, `RestFieldPaths`>(`name`, `fields`): [`TableDefinition`](/api/classes/server.TableDefinition)\<[`VObject`](/api/classes/values.VObject)\<[`Expand`](/api/modules/server#expand)\<\{ \[Property in string | number | symbol]?: Exclude\<Infer\<Fields\[Property]>, undefined> } & \{ \[Property in string | number | symbol]: Infer\<Fields\[Property]> }>, `Fields`, `"required"`, \{ \[Property in string | number | symbol]: Property | \`$\{Property & string}.$\{Fields\[Property]\["fieldPaths"]}\` }\[keyof `Fields`] & `string`>, [`Expand`](/api/modules/server#expand)\<`Record`\<`IndexName`, \[`FirstFieldPath`, ...RestFieldPaths\[], `"_creationTime"`]>>, \{}, \{}, `false`>

Define an index on this table.

To learn about indexes, see [Defining Indexes](/database/reading-data/indexes/indexes).

#### Type parameters

| Name | Type |
| :- | :- |
| `IndexName` | extends `string` |
| `FirstFieldPath` | extends `string` |
| `RestFieldPaths` | extends `ExtractFieldPaths`\<[`VObject`](/api/classes/values.VObject)\<[`Expand`](/api/modules/server#expand)\<\{ \[Property in string \| number \| symbol]?: Exclude\<Infer\<Fields\[Property]>, undefined> } & \{ \[Property in string \| number \| symbol]: Infer\<Fields\[Property]> }>, `Fields`, `"required"`, \{ \[Property in string \| number \| symbol]: Property \| \`$\{Property & string}.$\{Fields\[Property]\["fieldPaths"]}\` }\[keyof `Fields`] & `string`>>\[] |

#### Parameters

| Name | Type | Description |
| :- | :- | :- |
| `name` | `IndexName` | The name of the index. |
| `fields` | \[`FirstFieldPath`, ...RestFieldPaths\[]] | The fields to index, in order. Must specify at least one field. |

#### Returns

[`TableDefinition`](/api/classes/server.TableDefinition)\<[`VObject`](/api/classes/values.VObject)\<[`Expand`](/api/modules/server#expand)\<\{ \[Property in string | number | symbol]?: Exclude\<Infer\<Fields\[Property]>, undefined> } & \{ \[Property in string | number | symbol]: Infer\<Fields\[Property]> }>, `Fields`, `"required"`, \{ \[Property in string | number | symbol]: Property | \`$\{Property & string}.$\{Fields\[Property]\["fieldPaths"]}\` }\[keyof `Fields`] & `string`>, [`Expand`](/api/modules/server#expand)\<`Record`\<`IndexName`, \[`FirstFieldPath`, ...RestFieldPaths\[], `"_creationTime"`]>>, \{}, \{}, `false`>

A [TableDefinition](/api/classes/server.TableDefinition) with this index included.

#### Inherited from

[TableDefinition](/api/classes/server.TableDefinition).[index](/api/classes/server.TableDefinition#index)

▸ **index**\<`IndexName`, `FirstFieldPath`, `RestFieldPaths`>(`name`, `indexConfig`): [`TableDefinition`](/api/classes/server.TableDefinition)\<[`VObject`](/api/classes/values.VObject)\<[`Expand`](/api/modules/server#expand)\<\{ \[Property in string | number | symbol]?: Exclude\<Infer\<Fields\[Property]>, undefined> } & \{ \[Property in string | number | symbol]: Infer\<Fields\[Property]> }>, `Fields`, `"required"`, \{ \[Property in string | number | symbol]: Property | \`$\{Property & string}.$\{Fields\[Property]\["fieldPaths"]}\` }\[keyof `Fields`] & `string`>, \{}, \{}, \{}, `false`>

Define a staged index on this table.

For large tables, index backfill can be slow. Staging an index allows you
to push the schema and enable the index later.

If `staged` is `true`, the index will be staged and will not be enabled
until the staged flag is removed. Staged indexes do not block push
completion. Staged indexes cannot be used in queries.

To learn about indexes, see [Defining Indexes](/database/reading-data/indexes/indexes).

#### Type parameters

| Name | Type |
| :- | :- |
| `IndexName` | extends `string` |
| `FirstFieldPath` | extends `string` |
| `RestFieldPaths` | extends `ExtractFieldPaths`\<[`VObject`](/api/classes/values.VObject)\<[`Expand`](/api/modules/server#expand)\<\{ \[Property in string \| number \| symbol]?: Exclude\<Infer\<Fields\[Property]>, undefined> } & \{ \[Property in string \| number \| symbol]: Infer\<Fields\[Property]> }>, `Fields`, `"required"`, \{ \[Property in string \| number \| symbol]: Property \| \`$\{Property & string}.$\{Fields\[Property]\["fieldPaths"]}\` }\[keyof `Fields`] & `string`>>\[] |

#### Parameters

| Name | Type | Description |
| :- | :- | :- |
| `name` | `IndexName` | The name of the index. |
| `indexConfig` | `Object` | The index configuration object. |
| `indexConfig.fields` | \[`FirstFieldPath`, ...RestFieldPaths\[]] | The fields to index, in order. Must specify at least one field. |
| `indexConfig.staged` | `true` | Whether the index should be staged. For large tables, index backfill can be slow. Staging an index allows you to push the schema and enable the index later. If `staged` is `true`, the index will be staged and will not be enabled until the staged flag is removed. Staged indexes do not block push completion. Staged indexes cannot be used in queries. |

#### Returns

[`TableDefinition`](/api/classes/server.TableDefinition)\<[`VObject`](/api/classes/values.VObject)\<[`Expand`](/api/modules/server#expand)\<\{ \[Property in string | number | symbol]?: Exclude\<Infer\<Fields\[Property]>, undefined> } & \{ \[Property in string | number | symbol]: Infer\<Fields\[Property]> }>, `Fields`, `"required"`, \{ \[Property in string | number | symbol]: Property | \`$\{Property & string}.$\{Fields\[Property]\["fieldPaths"]}\` }\[keyof `Fields`] & `string`>, \{}, \{}, \{}, `false`>

A [TableDefinition](/api/classes/server.TableDefinition) with this index included.

#### Inherited from

[TableDefinition](/api/classes/server.TableDefinition).[index](/api/classes/server.TableDefinition#index)

***

### searchIndex

▸ **searchIndex**\<`IndexName`, `SearchField`, `FilterFields`>(`name`, `indexConfig`): [`TableDefinition`](/api/classes/server.TableDefinition)\<[`VObject`](/api/classes/values.VObject)\<[`Expand`](/api/modules/server#expand)\<\{ \[Property in string | number | symbol]?: Exclude\<Infer\<Fields\[Property]>, undefined> } & \{ \[Property in string | number | symbol]: Infer\<Fields\[Property]> }>, `Fields`, `"required"`, \{ \[Property in string | number | symbol]: Property | \`$\{Property & string}.$\{Fields\[Property]\["fieldPaths"]}\` }\[keyof `Fields`] & `string`>, \{}, [`Expand`](/api/modules/server#expand)\<`Record`\<`IndexName`, \{ `searchField`: `SearchField` ; `filterFields`: `FilterFields`  }>>, \{}, `false`>

Define a search index on this table.

To learn about search indexes, see [Search](/search/text-search).

#### Type parameters

| Name | Type |
| :- | :- |
| `IndexName` | extends `string` |
| `SearchField` | extends `string` |
| `FilterFields` | extends `string` = `never` |

#### Parameters

| Name | Type | Description |
| :- | :- | :- |
| `name` | `IndexName` | The name of the index. |
| `indexConfig` | `Object` | The search index configuration object. |
| `indexConfig.searchField` | `SearchField` | The field to index for full text search. This must be a field of type `string`. |
| `indexConfig.filterFields?` | `FilterFields`\[] | Additional fields to index for fast filtering when running search queries. |
| `indexConfig.staged?` | `false` | Whether the index should be staged. For large tables, index backfill can be slow. Staging an index allows you to push the schema and enable the index later. If `staged` is `true`, the index will be staged and will not be enabled until the staged flag is removed. Staged indexes do not block push completion. Staged indexes cannot be used in queries. |

#### Returns

[`TableDefinition`](/api/classes/server.TableDefinition)\<[`VObject`](/api/classes/values.VObject)\<[`Expand`](/api/modules/server#expand)\<\{ \[Property in string | number | symbol]?: Exclude\<Infer\<Fields\[Property]>, undefined> } & \{ \[Property in string | number | symbol]: Infer\<Fields\[Property]> }>, `Fields`, `"required"`, \{ \[Property in string | number | symbol]: Property | \`$\{Property & string}.$\{Fields\[Property]\["fieldPaths"]}\` }\[keyof `Fields`] & `string`>, \{}, [`Expand`](/api/modules/server#expand)\<`Record`\<`IndexName`, \{ `searchField`: `SearchField` ; `filterFields`: `FilterFields`  }>>, \{}, `false`>

A [TableDefinition](/api/classes/server.TableDefinition) with this search index included.

#### Inherited from

[TableDefinition](/api/classes/server.TableDefinition).[searchIndex](/api/classes/server.TableDefinition#searchindex)

▸ **searchIndex**\<`IndexName`, `SearchField`, `FilterFields`>(`name`, `indexConfig`): [`TableDefinition`](/api/classes/server.TableDefinition)\<[`VObject`](/api/classes/values.VObject)\<[`Expand`](/api/modules/server#expand)\<\{ \[Property in string | number | symbol]?: Exclude\<Infer\<Fields\[Property]>, undefined> } & \{ \[Property in string | number | symbol]: Infer\<Fields\[Property]> }>, `Fields`, `"required"`, \{ \[Property in string | number | symbol]: Property | \`$\{Property & string}.$\{Fields\[Property]\["fieldPaths"]}\` }\[keyof `Fields`] & `string`>, \{}, \{}, \{}, `false`>

Define a staged search index on this table.

For large tables, index backfill can be slow. Staging an index allows you
to push the schema and enable the index later.

If `staged` is `true`, the index will be staged and will not be enabled
until the staged flag is removed. Staged indexes do not block push
completion. Staged indexes cannot be used in queries.

To learn about search indexes, see [Search](/search/text-search).

#### Type parameters

| Name | Type |
| :- | :- |
| `IndexName` | extends `string` |
| `SearchField` | extends `string` |
| `FilterFields` | extends `string` = `never` |

#### Parameters

| Name | Type | Description |
| :- | :- | :- |
| `name` | `IndexName` | The name of the index. |
| `indexConfig` | `Object` | The search index configuration object. |
| `indexConfig.searchField` | `SearchField` | The field to index for full text search. This must be a field of type `string`. |
| `indexConfig.filterFields?` | `FilterFields`\[] | Additional fields to index for fast filtering when running search queries. |
| `indexConfig.staged` | `true` | Whether the index should be staged. For large tables, index backfill can be slow. Staging an index allows you to push the schema and enable the index later. If `staged` is `true`, the index will be staged and will not be enabled until the staged flag is removed. Staged indexes do not block push completion. Staged indexes cannot be used in queries. |

#### Returns

[`TableDefinition`](/api/classes/server.TableDefinition)\<[`VObject`](/api/classes/values.VObject)\<[`Expand`](/api/modules/server#expand)\<\{ \[Property in string | number | symbol]?: Exclude\<Infer\<Fields\[Property]>, undefined> } & \{ \[Property in string | number | symbol]: Infer\<Fields\[Property]> }>, `Fields`, `"required"`, \{ \[Property in string | number | symbol]: Property | \`$\{Property & string}.$\{Fields\[Property]\["fieldPaths"]}\` }\[keyof `Fields`] & `string`>, \{}, \{}, \{}, `false`>

A [TableDefinition](/api/classes/server.TableDefinition) with this search index included.

#### Inherited from

[TableDefinition](/api/classes/server.TableDefinition).[searchIndex](/api/classes/server.TableDefinition#searchindex)

***

### vectorIndex

▸ **vectorIndex**\<`IndexName`, `VectorField`, `FilterFields`>(`name`, `indexConfig`): [`TableDefinition`](/api/classes/server.TableDefinition)\<[`VObject`](/api/classes/values.VObject)\<[`Expand`](/api/modules/server#expand)\<\{ \[Property in string | number | symbol]?: Exclude\<Infer\<Fields\[Property]>, undefined> } & \{ \[Property in string | number | symbol]: Infer\<Fields\[Property]> }>, `Fields`, `"required"`, \{ \[Property in string | number | symbol]: Property | \`$\{Property & string}.$\{Fields\[Property]\["fieldPaths"]}\` }\[keyof `Fields`] & `string`>, \{}, \{}, [`Expand`](/api/modules/server#expand)\<`Record`\<`IndexName`, \{ `vectorField`: `VectorField` ; `dimensions`: `number` ; `filterFields`: `FilterFields`  }>>, `false`>

Define a vector index on this table.

To learn about vector indexes, see [Vector Search](/search/vector-search).

#### Type parameters

| Name | Type |
| :- | :- |
| `IndexName` | extends `string` |
| `VectorField` | extends `string` |
| `FilterFields` | extends `string` = `never` |

#### Parameters

| Name | Type | Description |
| :- | :- | :- |
| `name` | `IndexName` | The name of the index. |
| `indexConfig` | `Object` | The vector index configuration object. |
| `indexConfig.vectorField` | `VectorField` | The field to index for vector search. This must be a field of type `v.array(v.float64())` (or a union) |
| `indexConfig.dimensions` | `number` | The length of the vectors indexed. This must be between 2 and 2048 inclusive. |
| `indexConfig.filterFields?` | `FilterFields`\[] | Additional fields to index for fast filtering when running vector searches. |
| `indexConfig.staged?` | `false` | Whether the index should be staged. For large tables, index backfill can be slow. Staging an index allows you to push the schema and enable the index later. If `staged` is `true`, the index will be staged and will not be enabled until the staged flag is removed. Staged indexes do not block push completion. Staged indexes cannot be used in queries. |

#### Returns

[`TableDefinition`](/api/classes/server.TableDefinition)\<[`VObject`](/api/classes/values.VObject)\<[`Expand`](/api/modules/server#expand)\<\{ \[Property in string | number | symbol]?: Exclude\<Infer\<Fields\[Property]>, undefined> } & \{ \[Property in string | number | symbol]: Infer\<Fields\[Property]> }>, `Fields`, `"required"`, \{ \[Property in string | number | symbol]: Property | \`$\{Property & string}.$\{Fields\[Property]\["fieldPaths"]}\` }\[keyof `Fields`] & `string`>, \{}, \{}, [`Expand`](/api/modules/server#expand)\<`Record`\<`IndexName`, \{ `vectorField`: `VectorField` ; `dimensions`: `number` ; `filterFields`: `FilterFields`  }>>, `false`>

A [TableDefinition](/api/classes/server.TableDefinition) with this vector index included.

#### Inherited from

[TableDefinition](/api/classes/server.TableDefinition).[vectorIndex](/api/classes/server.TableDefinition#vectorindex)

▸ **vectorIndex**\<`IndexName`, `VectorField`, `FilterFields`>(`name`, `indexConfig`): [`TableDefinition`](/api/classes/server.TableDefinition)\<[`VObject`](/api/classes/values.VObject)\<[`Expand`](/api/modules/server#expand)\<\{ \[Property in string | number | symbol]?: Exclude\<Infer\<Fields\[Property]>, undefined> } & \{ \[Property in string | number | symbol]: Infer\<Fields\[Property]> }>, `Fields`, `"required"`, \{ \[Property in string | number | symbol]: Property | \`$\{Property & string}.$\{Fields\[Property]\["fieldPaths"]}\` }\[keyof `Fields`] & `string`>, \{}, \{}, \{}, `false`>

Define a staged vector index on this table.

For large tables, index backfill can be slow. Staging an index allows you
to push the schema and enable the index later.

If `staged` is `true`, the index will be staged and will not be enabled
until the staged flag is removed. Staged indexes do not block push
completion. Staged indexes cannot be used in queries.

To learn about vector indexes, see [Vector Search](/search/vector-search).

#### Type parameters

| Name | Type |
| :- | :- |
| `IndexName` | extends `string` |
| `VectorField` | extends `string` |
| `FilterFields` | extends `string` = `never` |

#### Parameters

| Name | Type | Description |
| :- | :- | :- |
| `name` | `IndexName` | The name of the index. |
| `indexConfig` | `Object` | The vector index configuration object. |
| `indexConfig.vectorField` | `VectorField` | The field to index for vector search. This must be a field of type `v.array(v.float64())` (or a union) |
| `indexConfig.dimensions` | `number` | The length of the vectors indexed. This must be between 2 and 2048 inclusive. |
| `indexConfig.filterFields?` | `FilterFields`\[] | Additional fields to index for fast filtering when running vector searches. |
| `indexConfig.staged` | `true` | Whether the index should be staged. For large tables, index backfill can be slow. Staging an index allows you to push the schema and enable the index later. If `staged` is `true`, the index will be staged and will not be enabled until the staged flag is removed. Staged indexes do not block push completion. Staged indexes cannot be used in queries. |

#### Returns

[`TableDefinition`](/api/classes/server.TableDefinition)\<[`VObject`](/api/classes/values.VObject)\<[`Expand`](/api/modules/server#expand)\<\{ \[Property in string | number | symbol]?: Exclude\<Infer\<Fields\[Property]>, undefined> } & \{ \[Property in string | number | symbol]: Infer\<Fields\[Property]> }>, `Fields`, `"required"`, \{ \[Property in string | number | symbol]: Property | \`$\{Property & string}.$\{Fields\[Property]\["fieldPaths"]}\` }\[keyof `Fields`] & `string`>, \{}, \{}, \{}, `false`>

A [TableDefinition](/api/classes/server.TableDefinition) with this vector index included.

#### Inherited from

[TableDefinition](/api/classes/server.TableDefinition).[vectorIndex](/api/classes/server.TableDefinition#vectorindex)

***

### self

▸ `Protected` **self**(): [`TableDefinition`](/api/classes/server.TableDefinition)\<[`VObject`](/api/classes/values.VObject)\<[`Expand`](/api/modules/server#expand)\<\{ \[Property in string | number | symbol]?: Exclude\<Infer\<Fields\[Property]>, undefined> } & \{ \[Property in string | number | symbol]: Infer\<Fields\[Property]> }>, `Fields`, `"required"`, \{ \[Property in string | number | symbol]: Property | \`$\{Property & string}.$\{Fields\[Property]\["fieldPaths"]}\` }\[keyof `Fields`] & `string`>, \{}, \{}, \{}, `false`>

Work around for [https://github.com/microsoft/TypeScript/issues/57035](https://github.com/microsoft/TypeScript/issues/57035)

#### Returns

[`TableDefinition`](/api/classes/server.TableDefinition)\<[`VObject`](/api/classes/values.VObject)\<[`Expand`](/api/modules/server#expand)\<\{ \[Property in string | number | symbol]?: Exclude\<Infer\<Fields\[Property]>, undefined> } & \{ \[Property in string | number | symbol]: Infer\<Fields\[Property]> }>, `Fields`, `"required"`, \{ \[Property in string | number | symbol]: Property | \`$\{Property & string}.$\{Fields\[Property]\["fieldPaths"]}\` }\[keyof `Fields`] & `string`>, \{}, \{}, \{}, `false`>

#### Inherited from

[TableDefinition](/api/classes/server.TableDefinition).[self](/api/classes/server.TableDefinition#self)


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