Skip to main content

Data Types

Tigris supports all of the TypeScript types while also providing support for custom types via classes.

Strings

@TigrisCollection("post")
export class Post {
@Field()
title: string;

@Field({ maxLength: 100 })
name: string;

@Field({ default: "default value" })
author: string;

@Field(TigrisDataTypes.BYTE_STRING)
media: string;
}

Boolean

@TigrisCollection("post")
export class Post {
@Field()
pinned: boolean;

@Field({ default: false })
active: boolean;
}

Numbers

@TigrisCollection("post")
export class Post {
@Field(TigrisDataTypes.INT32, { default: 0 })
viewCount: number;

@Field(TigrisDataTypes.INT64)
authorId: bigint;

@Field(TigrisDataTypes.INT64)
postId: string;
}

Javascript number type can only represent integer values from -9007199254740991 to 9007199254740991. If your collection field has a use-case for 64-bit integers, we recommend using bigint or string field type to represent your integers.

Dates

@TigrisCollection("post")
export class Post {
@Field({ timestamp: "createdAt" })
createdAt: Date;

@Field({ timestamp: "updatedAt" })
updatedAt: Date;

@Field()
publishedAt: Date;
}

UUIDs

@TigrisCollection("post")
export class Post {
@Field(TigrisDataTypes.UUID)
id: string;
}

Bytes

Fields of bytes type can be used to store raw bytes such as images, videos, etc.

@TigrisCollection("post")
export class Post {
@Field(TigrisDataTypes.BYTE_STRING)
media: string;
}

Objects

User-defined classes and objects are supported. Fields can be of any type, there is no restriction.

export class Bio {
@Field()
text: string;

@Field({ timestamp: "createdAt" })
createdAt: Date;
}

@TigrisCollection("authors")
export class Author {
@Field()
bio: Bio;

@Field()
details: object;
}

Arrays

Arrays of all the above types are supported. There is no restriction.

@TigrisCollection("post")
export class Post {
@Field({ elements: TigrisDataTypes.STRING })
tags: string[];

@Field({ elements: Comment })
comments: Comment[];
}

Vectors

Tigris supports storing vector embeddings and vector search. Vectors are represented as arrays of numbers.

// 1536 floats total for ada-002
@SearchField({ dimensions: 1536 })
vector: number[];