Open jiashengguo opened 1 year ago
As an alternative, you may want to take a look at a Prisma extension library ZenStack that we are currently working on. The schema is fully compatible with Prisma Schema, and besides supporting importing other schema files, we also support model inheritance to make your scheme DRY(Don’t repeat yourself). For example, you could have two separate schema files like this(Sorry that the highlight is not working in the markdown, but works well with our Zmodel VScode extension):
abstract model Base {
id String @id
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
// author has full access
@@allow('all', auth() == author)
}
import "base"
model User extends Basic {
name String
}
model User extends Basic { name String }
The generated prisma.schema would be like this:
```prisma
/// @@allow('create,read', true)
/// @@allow('update,delete', auth() == this)
model User {
name String
id String @id()
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt()
}
/// @@allow('create,read', true)
/// @@allow('update,delete', auth() == this)
model Post {
title String
id String @id()
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt()
}