Prisma ORM: Modern Database Access in Node.js
Prisma provides type-safe database access, migrations, and a visual data browser-popular in TypeScript full stack projects.
Schema Definition
model User {
id String @id @default(cuid())
email String @unique
posts Post[]
createdAt DateTime @default(now())
}
model Post {
id String @id @default(cuid())
title String
author User @relation(fields: [authorId], references: [id])
authorId String
}
Queries
const users = await prisma.user.findMany({
include: { posts: true },
where: { email: { contains: '@company.com' } },
});
Migrations
npx prisma migrate dev applies schema changes in development. Use prisma generate after schema edits to refresh the client.
Conclusion
Prisma accelerates CRUD APIs and pairs well with Next.js API routes and tRPC. For complex raw SQL, fall back to $queryRaw while keeping Prisma for the majority of access patterns.