Skip to main content
ChameleonDB provides a strongly-typed field system with compile-time validation. Each field must have an explicit type.

Basic Syntax

Example:

Scalar Types

UUID

Universally unique identifier (RFC 4122):
uuid
128-bit universally unique identifier. Commonly used for primary keys.Example:
SQL Mapping: UUID (PostgreSQL)

String

Variable-length text data:
string
UTF-8 encoded text of arbitrary length.Example:
SQL Mapping: TEXT (PostgreSQL)

Int

Signed integer:
int
64-bit signed integer (-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807).Example:
SQL Mapping: BIGINT (PostgreSQL)

Decimal

Arbitrary precision decimal number:
decimal
Fixed-point decimal number with arbitrary precision. Suitable for currency and financial calculations.Example:
SQL Mapping: NUMERIC (PostgreSQL)

Bool

Boolean value:
bool
True or false value.Example:
SQL Mapping: BOOLEAN (PostgreSQL)

Timestamp

Date and time with timezone:
timestamp
Date and time value with timezone information.Example:
SQL Mapping: TIMESTAMPTZ (PostgreSQL)

Float

Floating-point number:
float
64-bit floating-point number (IEEE 754 double precision).Example:
SQL Mapping: DOUBLE PRECISION (PostgreSQL)
For currency or precise calculations, use decimal instead of float to avoid rounding errors.

Special Types

Vector

Fixed-size vector for embeddings:
vector
Fixed-size vector of N dimensions for machine learning embeddings.Syntax:
Example:
Requirements:
  • Must specify dimension count
  • Typically used with @vector annotation
  • Dimension must be a positive integer
SQL Mapping: VECTOR(N) (PostgreSQL with pgvector extension)

Collection Types

Array

Ordered collection of values:
array
Array of values of a single type.Syntax:
Example:
SQL Mapping: type[] (PostgreSQL array type)

Type Reference Table

Complete Example

Type Validation

ChameleonDB validates field types at compile time:
Type Existence - All types must be recognized
Vector Dimensions - vector(N) requires a valid dimension count
Array Elements - Array element types must be valid scalar types
Default Values - Default values must match the field type

Best Practices

Use uuid for primary keys - UUIDs prevent ID collisions and are globally unique
Use decimal for money - Never use float for currency to avoid rounding errors
Use timestamp for dates - Always use timezone-aware timestamps
Be explicit - Always specify types; ChameleonDB does not infer types
Avoid using nullable unless truly necessary. Explicit null handling makes your domain model clearer.

Next Steps

Constraints

Add validation with constraints

Relations

Define entity relationships