cocomon

Native types

Provider-specific @db.* support for PostgreSQL and SQLite.

Native types

comon_orm supports a deliberate subset of provider-specific native types.

Use native types when you need a more exact database shape than the default logical scalar mapping.

PostgreSQL

Schema attributeTypical logical type
@db.VarChar(255)String
@db.TextString
@db.JsonJson
@db.JsonBJson
@db.ByteABytes
@db.NumericDecimal
@db.TimestampDateTime
@db.TimestamptzDateTime
@db.UuidString

Example:

model Event {
  id        String   @id @db.Uuid
  payload   Json     @db.JsonB
  createdAt DateTime @db.Timestamptz
}

SQLite

Schema attributeTypical logical type
@db.IntegerInt
@db.NumericDecimal
@db.RealFloat
@db.TextString
@db.BlobBytes

Example:

model Attachment {
  id      Int   @id @default(autoincrement())
  data    Bytes @db.Blob
  version Int   @db.Integer
}

Practical rules

  • prefer logical types first and reach for @db.* only when the database shape matters
  • keep PostgreSQL and SQLite schemas intentionally separate when you need provider-specific storage behavior
  • review native-type changes carefully in migrations because they can become lossy type transitions

On this page