Working with Scalar Types

1. Using String Type

Native MappingPostgresMySQL
Defaulttextvarchar(191)
@db.VarChar(n)varchar(n)varchar(n)
@db.Texttexttext
@db.Char(n)char(n)char(n)

2. Using Int Type

MappingDetail
Default32-bit signed integer
@db.SmallInt16-bit
@db.IntegerExplicit 32-bit
Range-2,147,483,648 .. 2,147,483,647

3. Using BigInt Type

AspectDetail
JS typebigint primitive
SerializationJSON.stringify fails — use .toString()
Native@db.BigInt
Warning: BigInts do not serialize to JSON by default. Add a global JSON serializer or convert to string before sending over HTTP.

4. Using Float Type

MappingDetail
Defaultdouble precision (64-bit IEEE 754)
@db.Real32-bit
PrecisionSubject to floating-point rounding

5. Using Decimal Type

AspectDetail
JS classPrisma.Decimal (Decimal.js)
Precision@db.Decimal(precision, scale)
Use caseMoney, scientific values
SQLiteNot supported (use Float/String)

Example: Decimal arithmetic

import { Prisma } from "@prisma/client";
const total = new Prisma.Decimal("19.99").mul(3);
await prisma.invoice.create({ data: { total } });

6. Using Boolean Type

MappingDetail
PG/MySQLboolean / tinyint(1)
Defaults@default(false)
SQL Serverbit

7. Using DateTime Type

MappingDetail
Defaulttimestamp(3) UTC
@db.Timestamptz(6)timestamp with timezone (PG)
@db.DateDate only
@db.TimeTime only

8. Using Json Type

AspectDetail
PGjsonb (default)
MySQLjson
SQLiteStored as text
TS typePrisma.JsonValue
Null distinctionPrisma.JsonNull vs Prisma.DbNull

9. Using Bytes Type

AspectDetail
JS typeUint8Array (Prisma 6+)
PGbytea
Use caseBinary blobs, hashes, encrypted payloads

10. Using Unsupported Type

AspectDetail
Syntaxfield Unsupported("polygon")
Read/WriteOnly via raw SQL
Use casePostGIS geometry, custom types