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.