Skip to main content

Class: TableDefinition<DocumentType, Indexes, SearchIndexes, VectorIndexes>

server.TableDefinition

The definition of a table within a schema.

This should be produced by using defineTable.

Type parameters

NameType
DocumentTypeextends Validator<any, any, any> = Validator<any, any, any>
Indexesextends GenericTableIndexes =
SearchIndexesextends GenericTableSearchIndexes =
VectorIndexesextends GenericTableVectorIndexes =

Properties

validator

validator: DocumentType

Defined in

server/schema.ts:166

Methods

index

index<IndexName, FirstFieldPath, RestFieldPaths>(name, fields): TableDefinition<DocumentType, Expand<Indexes & Record<IndexName, [FirstFieldPath, ...RestFieldPaths[], "_creationTime"]>>, SearchIndexes, VectorIndexes>

Define an index on this table.

To learn about indexes, see Defining Indexes.

Type parameters

NameType
IndexNameextends string
FirstFieldPathextends any
RestFieldPathsextends ExtractFieldPaths<DocumentType>[]

Parameters

NameTypeDescription
nameIndexNameThe name of the index.
fields[FirstFieldPath, ...RestFieldPaths[]]The fields to index, in order. Must specify at least one field.

Returns

TableDefinition<DocumentType, Expand<Indexes & Record<IndexName, [FirstFieldPath, ...RestFieldPaths[], "_creationTime"]>>, SearchIndexes, VectorIndexes>

A TableDefinition with this index included.

Defined in

server/schema.ts:188


searchIndex

searchIndex<IndexName, SearchField, FilterFields>(name, indexConfig): TableDefinition<DocumentType, Indexes, Expand<SearchIndexes & Record<IndexName, { searchField: SearchField ; filterFields: FilterFields }>>, VectorIndexes>

Define a search index on this table.

To learn about search indexes, see Search.

Type parameters

NameType
IndexNameextends string
SearchFieldextends any
FilterFieldsextends any = never

Parameters

NameTypeDescription
nameIndexNameThe name of the index.
indexConfigObjectThe search index configuration object.
indexConfig.searchFieldSearchFieldThe 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.

Returns

TableDefinition<DocumentType, Indexes, Expand<SearchIndexes & Record<IndexName, { searchField: SearchField ; filterFields: FilterFields }>>, VectorIndexes>

A TableDefinition with this search index included.

Defined in

server/schema.ts:222


vectorIndex

vectorIndex<IndexName, VectorField, FilterFields>(name, indexConfig): TableDefinition<DocumentType, Indexes, SearchIndexes, Expand<VectorIndexes & Record<IndexName, { vectorField: VectorField ; dimensions: number ; filterFields: FilterFields }>>>

Define a vector index on this table.

To learn about vector indexes, see Vector Search.

Type parameters

NameType
IndexNameextends string
VectorFieldextends any
FilterFieldsextends any = never

Parameters

NameTypeDescription
nameIndexNameThe name of the index.
indexConfigObjectThe vector index configuration object.
indexConfig.vectorFieldVectorFieldThe field to index for vector search. This must be a field of type v.array(v.float64()) (or a union)
indexConfig.dimensionsnumberThe 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.

Returns

TableDefinition<DocumentType, Indexes, SearchIndexes, Expand<VectorIndexes & Record<IndexName, { vectorField: VectorField ; dimensions: number ; filterFields: FilterFields }>>>

A TableDefinition with this vector index included.

Defined in

server/schema.ts:263


self

Protected self(): TableDefinition<DocumentType, Indexes, SearchIndexes, VectorIndexes>

Work around for https://github.com/microsoft/TypeScript/issues/57035

Returns

TableDefinition<DocumentType, Indexes, SearchIndexes, VectorIndexes>

Defined in

server/schema.ts:298