Skip to main content

Field Types

Basic Types

TypeSQLitePostgreSQLMySQL
stringtexttextvarchar(255)
texttexttexttext
integer / intintegerintegerint
bigintintegerbigintbigint
boolean / boolinteger (mode: boolean)booleanboolean
floatrealdoublePrecisiondouble
decimaltextnumericdecimal
datetime / timestampinteger (mode: timestamp)timestampdatetime
dateinteger (mode: timestamp)datedate
jsontextjsonbjson
uuidtextuuidvarchar(36)

Special Types

Enum

Define a field with a fixed set of allowed values:

brizzle model order status:enum:pending,paid,shipped,delivered

SQLite:

status: text("status", { enum: ["pending", "paid", "shipped", "delivered"] }).notNull()

PostgreSQL:

export const statusEnum = pgEnum("status", ["pending", "paid", "shipped", "delivered"]);
// ...
status: statusEnum("status").notNull()

MySQL:

status: mysqlEnum("status", ["pending", "paid", "shipped", "delivered"]).notNull()

References

Create a foreign key reference to another table:

brizzle model comment authorId:references:user postId:references:post

Generates:

authorId: integer("author_id").references(() => users.id).notNull(),
postId: integer("post_id").references(() => posts.id).notNull()

The reference target is automatically pluralized (e.g., userusers).

Field Modifiers

Nullable (?)

Make a field optional by adding ? to the field name or type:

# These are equivalent:
brizzle model user bio:text?
brizzle model user bio?:text

Without ?, fields are notNull() by default.

Unique (:unique)

Add a unique constraint:

brizzle model user email:string:unique

Generates:

email: text("email").notNull().unique()

Combined Modifiers

You can combine nullable and unique:

brizzle model user email:string:unique nickname?:unique

Field Syntax

The full field syntax is:

name[?][:type[?]][:modifier][:enum_values]

Examples

DefinitionResult
titletitle: text, notNull
title:stringtitle: text, notNull
bio:text?bio: text, nullable
bio?bio: text, nullable
email:string:uniqueemail: text, notNull, unique
role:enum:admin,userrole: enum["admin","user"], notNull
userId:references:useruserId: integer, references users.id, notNull

Default Values

All generated models include:

  • id: Auto-incrementing integer (or UUID with --uuid)
  • createdAt: Timestamp, defaults to current time
  • updatedAt: Timestamp, defaults to current time

Disable timestamps with --no-timestamps.