Prisma is an ORM for Node.js and TypeScript. Instead of writing raw SQL strings in your code, you describe your data in a schema file, and Prisma generates a type-safe client you use to read and write your database. If you have ever misspelled a column name in a SQL string and only found out at runtime, Prisma exists to end that pain.
How does it work? You define your models in schema.prisma, run a command to create the tables, and Prisma generates a client. Then your queries are plain JavaScript function calls, with autocomplete and type checking in your editor.
// schema.prisma
model User {
id Int @id @default(autoincrement())
name String
email String @unique
posts Post[]
}
model Post {
id Int @id @default(autoincrement())
title String
author User @relation(fields: [authorId], references: [id])
authorId Int
}
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
// Create a user with a post, in one call
const user = await prisma.user.create({
data: {
name: 'Arhan',
email: 'arhan@example.com',
posts: { create: [{ title: 'Hello Prisma' }] },
},
include: { posts: true },
});
// Find all users, with their posts
const users = await prisma.user.findMany({ include: { posts: true } });
Prisma is great for beginners because the schema file is readable, the migrations are handled for you, and the editor autocomplete teaches you the API as you type. The built-in Prisma Studio also gives you a simple web UI to browse and edit your data while you learn.
When should you use Prisma? For any Node.js or TypeScript app with a relational database — blogs, shops, todo apps, dashboards. It supports PostgreSQL, MySQL, SQLite, and more, so the same code works whether you are learning on SQLite or deploying on Postgres.
The limits are worth knowing. Prisma is an abstraction, so for very complex queries raw SQL is sometimes clearer or faster. It also adds a build step and a learning curve of its own — you are learning Prisma's way of doing things, not SQL itself. Knowing basic SQL still helps a lot when something goes wrong.
Start today: set up Prisma with SQLite, define two models, and write the five basic operations — create, read one, read many, update, delete. That is the whole foundation, and it never changes.
Top comments (0)