jiashengguo / my-blog-app

0 stars 0 forks source link

test #1

Open jiashengguo opened 1 year ago

jiashengguo commented 1 year ago
model Space {
    id String @id @default(uuid())

    members SpaceUser[]

    //any user in the space can read the space
    @@allow('read', members?[user == auth()])
}
jiashengguo commented 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):

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()
}
jiashengguo commented 1 year ago