Skip to main content

Module types

Module types 

Source
Expand description

ORM type aliases — semantic DB types that map to SQL.

These are transparent type aliases (zero runtime cost). Users write them in struct fields; the #[model] proc macro reads the token name to determine the SQL column type for DDL generation and migrations.

Rust typeSQL (Postgres)SQL (SQLite)
VarcharVARCHAR(255)TEXT
TextTEXTTEXT
TimestampTIMESTAMPTEXT
TimestampTzTIMESTAMPTZTEXT
DateDATETEXT
DecimalNUMERICREAL
JsonJSONTEXT
JsonbJSONBTEXT
BytesBYTEABLOB

Native Rust types also work: i32 → INT, i64 → BIGINT, bool → BOOLEAN, String → VARCHAR(255), f32 → REAL, f64 → DOUBLE PRECISION.

Type Aliases§

Bytes
Maps to BYTEA (Postgres) / BLOB (SQLite).
Date
Maps to DATE.
Decimal
Maps to NUMERIC. Override precision/scale with #[col(precision = N, scale = N)].
Json
Maps to JSON.
Jsonb
Maps to JSONB.
Text
Maps to TEXT — unlimited length string.
Timestamp
Maps to TIMESTAMP (without time zone).
TimestampTz
Maps to TIMESTAMPTZ (with time zone).
Varchar
Maps to VARCHAR(255). Override length with #[col(max = N)].