prisma
Next-generation Node.js and TypeScript ORM with type-safe queries, migrations, and a visual schema editor.
Writing raw SQL is tedious and error-prone. Traditional ORMs like Sequelize give you objects but lose TypeScript types as soon as you query. You end up casting `any` everywhere and discovering schema mismatches at runtime.
Prisma has three parts: Schema (define models in schema.prisma), Migrate (generate SQL migrations from schema diffs), and Client (auto-generated, fully type-safe query builder). When you run `prisma generate`, it reads your schema and generates a `PrismaClient` with exact types for every model and query.
Set up Prisma with PostgreSQL
npm install prisma @prisma/client
npx prisma init
// prisma/schema.prisma
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
}
npx prisma migrate dev --name init
npx prisma generateUse it when
TypeScript backends with relational DBs (PostgreSQL, MySQL, SQLite, SQL Server). Projects where type safety and DX matter. Next.js full-stack apps.
Skip it when
If you need very complex SQL that Prisma can't express โ you can fall back to $queryRaw. Pure NoSQL (use Mongoose for MongoDB). Extreme performance-critical paths (Prisma adds overhead vs raw SQL).
Ready to explore the full API?
See every class, function, and relationship in an interactive graph.