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 type | SQL (Postgres) | SQL (SQLite) |
|---|---|---|
Varchar | VARCHAR(255) | TEXT |
Text | TEXT | TEXT |
Timestamp | TIMESTAMP | TEXT |
TimestampTz | TIMESTAMPTZ | TEXT |
Date | DATE | TEXT |
Decimal | NUMERIC | REAL |
Json | JSON | TEXT |
Jsonb | JSONB | TEXT |
Bytes | BYTEA | BLOB |
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). - Timestamp
Tz - Maps to
TIMESTAMPTZ(with time zone). - Varchar
- Maps to
VARCHAR(255). Override length with#[col(max = N)].