Prisma is a next-generation TypeScript ORM that provides auto-generated, type-safe database access for Node.js and TypeScript applications, supporting PostgreSQL, MySQL, SQLite, SQL Server, CockroachDB, and more (MongoDB support is planned for Prisma 8). Unlike traditional ORMs, Prisma uses a declarative schema file as the single source of truth, automatically generating a fully-typed client that eliminates runtime errors and provides unmatched developer experience. As of Prisma 7, the client is entirely Rust-free — powered by a WASM-based query compiler with built-in query plan caching — and configured via a prisma.config.ts file for explicit, type-safe project setup. The key insight: Prisma's schema-first approach ensures type safety flows from database to application code, while automatic query batching and a query caching layer optimize performance at scale.
What This Cheat Sheet Covers
This topic spans 18 focused tables and 159 indexed concepts, 111 flashcards. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
Table 1: Schema Data Types
These are the field types you write in your schema.prisma model, and each one quietly maps to both a native database column and a TypeScript type — that double mapping is what gives Prisma its end-to-end type safety. Most are obvious, but a few carry real gotchas worth knowing: reach for Decimal over Float for money, and remember BigInt returns a JavaScript BigInt that won't serialize to JSON without help.
| Type | Example | Description | |
|---|---|---|---|
name String | • Variable-length text • maps to VARCHAR in SQL databases and string in TypeScript. | ||
age Int | • 32-bit signed integer • maps to INTEGER in SQL and number in TypeScript. | ||
isActive Boolean | • True/false value • maps to BOOLEAN in PostgreSQL, TINYINT(1) in MySQL. | ||
createdAt DateTime | • Timestamp with timezone (PostgreSQL) or without (MySQL) • use @updatedAt for auto-update. | ||
price Float | • Double-precision floating point • use Decimal for financial calculations to avoid rounding errors. | ||
amount Decimal | • Arbitrary precision decimal using Decimal.js library • critical for currency and financial data. | ||
metadata Json | • Flexible JSON object storage • supports path-based filtering with database-specific operators in PostgreSQL. | ||
userId BigInt | • 64-bit integer for large numbers • returns JavaScript BigInt type, requiring special JSON serialization. | ||
file Bytes | • Binary data storage • maps to BYTEA (PostgreSQL), BLOB (MySQL); returns Buffer in Node.js. | ||
role Roleenum Role { USER ADMIN} | • Database-level enum type • provides type-safe constants; maps to native enums in PostgreSQL. | ||
custom Unsupported("GEOMETRY") | • Placeholder for database-specific types not natively supported • read-only in Prisma Client. |