DatabasePrismaDatabaseTypeScript
Prisma ORM: The Complete Developer Guide
Everything you need to build type-safe database applications with Prisma, from schema design to migrations.
Apr 2, 202613 min read13,500 views2000 words
Defining Your Schema
PRISMA
| 1 | model User { |
| 2 | id String @id @default(cuid()) |
| 3 | email String @unique |
| 4 | name String? |
| 5 | posts Post[] |
| 6 | createdAt DateTime @default(now()) |
| 7 | } |
| 8 | |
| 9 | model Post { |
| 10 | id String @id @default(cuid()) |
| 11 | title String |
| 12 | content String? |
| 13 | published Boolean @default(false) |
| 14 | author User @relation(fields: [authorId], references: [id]) |
| 15 | authorId String |
| 16 | } |