Schema reference
Supported scalar types, attributes, generator keys, and practical schema rules.
Schema reference
Use this page as a compact checklist. The detailed walkthroughs live in the dedicated pages for datasource/generator, models/fields, relations, enums, and native types.
Scalar types
Main scalar types recognized by comon_orm:
IntStringBooleanDateTimeFloatDecimalJsonBytesBigInt
See the full type mapping and attribute examples in Models and fields.
Datasource block
Typical keys:
providerurl
Examples:
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}datasource db {
provider = "sqlite"
url = "dev.db"
}See Datasource and generator for provider-specific setup guidance.
Generator block
Typical keys:
provideroutputsqliteHelper
generator client {
provider = "comon_orm"
output = "lib/generated/comon_orm_client.dart"
sqliteHelper = "flutter"
}sqliteHelper values:
vmforcomon_orm_sqliteflutterforcomon_orm_sqlite_flutter
See Datasource and generator for full setup combinations.
Common field attributes
| Attribute | Meaning |
|---|---|
@id | Primary key |
@default(...) | Default value such as autoincrement() or now() |
@unique | Unique column |
@updatedAt | Auto-refresh on update |
@map("...") | Map logical field name to database column name |
@relation(...) | Define relation ownership, references, and referential actions |
See Models and fields and Relations for full examples.
Model attributes
| Attribute | Meaning |
|---|---|
@@id([...]) | Compound primary key |
@@unique([...]) | Compound unique constraint |
@@index([...]) | Secondary index |
@@map("...") | Map logical model name to database table name |
Provider-specific native types
PostgreSQL currently includes support for types such as @db.VarChar(n), @db.Text, @db.Json, @db.JsonB, @db.ByteA, @db.Numeric, @db.Timestamp, @db.Timestamptz, and @db.Uuid.
SQLite currently includes support for @db.Integer, @db.Numeric, @db.Real, @db.Text, and @db.Blob.
See Native types for the supported subset with example schemas.
Validation behavior
The validator enforces relation ownership rules, unique-selector correctness for relation references, self-relation naming rules, and referential action constraints such as rejecting SetNull on non-nullable relation fields.