Schemas & Types

Data Types

TypeDescriptionExample
STRINGUTF-8 text'hello'
TEXTAlias for STRING'hello'
VARCHARAlias for STRING'hello'
INT64-bit signed integer42
FLOAT64-bit IEEE 7543.14
DECIMALArbitrary precision99.99
BOOLBooleantrue
TIMESTAMPUTC timestamp (nanosecond precision)now()
DATETIMEAlias for TIMESTAMP'2026-01-01T00:00Z'
UUID128-bit UUIDgen_uuid_v7()
GEOMETRYOGC geometry (WKB internally)ST_Point(-73.9, 40.7)
ARRAYOrdered listARRAY[1, 2, 3]
OBJECTNested document{ name: 'Alice' }

Schema Modes

Schemaless — No schema required. Fields can vary between documents. Types are inferred on insert. This is the default when you CREATE COLLECTION x.

Strict — Schema is defined at creation time and enforced on every write. O(1) field extraction via binary tuple format. Created with TYPE DOCUMENT STRICT (...).

Typeguards (Schemaless Validation)

Typeguards add write-time validation to schemaless collections without changing the storage format. Guarded fields are type-checked; unguarded fields pass freely.

CREATE TYPEGUARD ON users (
    email STRING REQUIRED CHECK (email LIKE '%@%.%'),
    age INT CHECK (age >= 0 AND age <= 150),
    role STRING DEFAULT 'user',
    updated_at TIMESTAMP VALUE now()
);
ModifierBehavior
REQUIREDField must be present and non-null
DEFAULTInject a value when the field is absent
VALUEAlways inject/overwrite (computed fields)
CHECKSQL boolean expression validated at write time
-- Modify guards
ALTER TYPEGUARD ON users ADD score FLOAT CHECK (score >= 0);
ALTER TYPEGUARD ON users DROP age;

-- Audit existing data against guards
VALIDATE TYPEGUARD ON users;

-- Graduate to strict schema
CONVERT COLLECTION users TO strict;

Schema Evolution (Strict Mode)

-- Add a column with a default (zero-downtime, multi-version reads)
ALTER COLLECTION orders ADD COLUMN region STRING DEFAULT 'us-east';

-- Drop a column
ALTER COLLECTION orders DROP COLUMN region;

ALTER ADD COLUMN uses multi-version reads — existing rows are served with the default value without rewriting storage. New writes include the column natively.

View page sourceLast updated on Apr 18, 2026 by Farhan Syah