SQL power, TypeScript comfort
Writing SQL strings in app code is error-prone: typos in column names only show up at runtime, and results come back untyped. Prisma is an ORM: you describe your data in schema.prisma, and it generates a fully typed client — prisma.dish.findMany() — with autocomplete for every field.
Schema + client
import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();
const cheap = await prisma.dish.findMany({
where: { price: { lt: 200 } },
orderBy: { price: "asc" },
select: { name: true, price: true },
});
console.log(cheap);
console.log("dishes:", await prisma.dish.count());- Real setup: npm i -D prisma && npm i @prisma/client, npx prisma init, then npx prisma migrate dev creates tables from the schema.
- npx prisma studio opens a visual data browser.
- Prisma supports PostgreSQL, MySQL, SQLite, SQL Server, CockroachDB and MongoDB.