Less Querying, More Chilling
Type Safety That Just... Works:
No typos, no guessing—I just typed user.
and the autocomplete took care of the rest. It made me feel like I knew my database inside out, even on a complex project.
const user = await prisma.user.findUnique({
where: { email: "user@example.com" }
});
Readable, Straightforward Queries
After switching from traditional ORMs, Prisma’s query syntax was like a breath of fresh air. It felt like writing regular JavaScript rather than decoding a cryptic SQL spell.
const users = await prisma.user.findMany({
where: { isActive: true },
select: { name: true, email: true }
});
Easy Migrations = No More Migration Anxiety
Migrations used to stress me out (for real). Every ORM migration setup seemed more complicated than the last, and I was not about to mess with raw SQL every time my data model changed. Prisma? Way simpler.
I updated my schema file to add a new isActive
field to User
:
model User {
id Int @id @default(autoincrement())
name String
email String @unique
isActive Boolean @default(true) // New field
}
Then, I ran one command:
npx prisma migrate dev --name "add_isActive_field"
That’s it. Prisma handled the rest. It created the migration files and updated the database without me sweating over a single line of SQL.
Prisma Studio: A Visual Database Playground
Midway through my project, I realized I needed to take a peek at my data to make sure everything was coming together as planned. Usually, that means digging through the console, writing queries, and checking results. But Prisma has Prisma Studio—a simple, visual tool for checking out my data, no code required.
I fired it up with a single command:
npx prisma studio
And there it was: my entire database laid out in a way I could browse and edit visually. It felt like Prisma had given me a behind-the-scenes pass to my data without all the usual query hassle.
One Schema File to Rule Them All
Setting up relationships and data models in a traditional ORM felt like piecing together a puzzle. But with Prisma, I defined everything in one neat schema.prisma
file. Relationships, fields, data types—it’s all in there, organized and easy to read.
Here’s a snippet of my project’s schema file:
model User {
id Int @id @default(autoincrement())
name String
email String @unique
posts Post[]
}
model Post {
id Int @id @default(autoincrement())
title String
content String?
author User @relation(fields: [userId], references: [id])
userId Int
}
It’s clean, easy to modify, and every relationship is right where I need it to be. I didn’t have to jump around files or piece together cryptic syntax.
Subscribe to my newsletter
Read articles from Harsh Singh directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by