Skip to main content
Version: 3.0 Alpha

Multi-file Schema

🔋 ZModel vs Prisma Schema

Prisma uses an implicit approach that simply merges all schema files in a folder. ZModel uses explicit import syntax for better clarity and flexibility.

When your schema grows large, you can break them down to smaller files and stitch them together using the import statement.

zenstack/user.zmodel
import './post'

model User {
id Int @id
posts Post[]
}
zenstack/post.zmodel
import './user'

model Post {
id Int @id
content String
author User @relation(fields: [authorId], references: [id])
authorId Int
}
zenstack/schema.zmodel
import './user'
import './post'

After type-checking, these files are merged into a single schema AST before passed to the downstream tools.

Comments
Feel free to ask questions, give feedback, or report issues.

Don't Spam


You can edit/delete your comments by going directly to the discussion, clicking on the 'comments' link below