Data and persistence
Prisma
Prisma ORM connects a declarative data model, generated database client, and migration workflow for Node.js and TypeScript applications.
What is Prisma and what does it do?
Prisma ORM is a database toolkit for Node.js and TypeScript applications. A Prisma schema describes models, fields, relations, and the selected database connection. Prisma Client is generated from that model to expose database operations through a typed API, while Prisma Migrate manages a history of schema changes.
These parts connect application code to a relational database without turning the database into an invisible implementation detail. The generated API improves discoverability and catches many shape mismatches during development. SQL behavior, constraints, indexes, transactions, and query plans still belong to the underlying database.
The schema is the starting contract
A model gives related decisions one readable home:
- field names and scalar types
- identifiers and unique values
- optional and required relations
- database provider and connection configuration
Generation translates that model into a client API. A schema edit alone does not safely change an existing database. The intended change must be represented by a reviewed migration and applied through an appropriate deployment process.
A small relational model
This schema defines authors and posts with an explicit foreign-key relation:
model User {
id Int @id @default(autoincrement())
email String @unique
posts Post[]
}
model Post {
id Int @id @default(autoincrement())
title String
authorId Int
author User @relation(fields: [authorId], references: [id])
}
The relation is visible from both models, while the database stores the link through authorId.
From model to database operation
The main path can be read in five steps:
Prisma schema -> generate -> Prisma Client -> database driver -> database
Application code calls the generated client. The client prepares an operation for the configured database, and the database remains responsible for execution, locking, constraints, and durable state. Migration files form a separate change path and should be reviewed as carefully as application code.
The database keeps final authority
Generated types do not prove that a query is efficient or that a migration is safe for existing data. Complex reporting, specialized indexes, unusual constraints, and heavily tuned paths may be clearer in SQL. Transactions must still be designed around real concurrency and failure behavior.
Prisma is useful when schema readability and typed access reduce application friction. It should remain a transparent interface to database behavior, not a reason to ignore that behavior.