You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Prisma extension library ZenStack we are building happens to share the same view with wladiston andLiam-Tait’s solution to use the schema as the single source of truth. 🤝
This is how the sample schema should be represented in ZenStack now:
enumRole {USERADMIN}modelCart {idString@id@default(uuid())customerProfile@relation(fields: [customerId], references: [id])customerIdString//Carts are only visible by owners@@allow('read', customerId == auth().id)//Admins can do anything with carts@@allow('all', auth().role == 'ADMIN')}
enumRole {USERADMIN}modelUser {idString@id@default(cuid())spacesSpaceUser[]// can be created by anyone, even not logged in@@allow('create', true)// can be read by users sharing any space@@allow('read', spaces?[space.members?[user == auth()]])// full access by oneself@@allow('all', auth() == this)}modelSpace {idString@id@default(uuid())membersSpaceUser[]// require login@@deny('all', auth() == null)// everyone can create a space@@allow('create', true)// any user in the space can read the space@@allow('read', members?[user == auth()])// space admin can update and delete@@allow('update,delete', members?[user == auth() && role == ADMIN])}
/*
* Model representing membership of a user in a space
*/
modelSpaceUser {idString@id@default(uuid())spaceSpace@relation(fields:[spaceId], references: [id], onDelete: Cascade)spaceIdStringuserUser@relation(fields: [userId], references: [id], onDelete: Cascade)userIdStringroleRole// require login@@deny('all', auth() == null)// space admin can create/update/delete@@allow('create,update,delete', space.members?[user == auth() && role == ADMIN])// user can read entries for spaces which he's a member of@@allow('read', space.members?[user == auth()])}
If you feel interested, there is a tutorial post I wrote about it:
We would really appreciate it if you could share your opinions by commenting or joining our Discord to help us make ZenStack the right thing to solve your problems.
The text was updated successfully, but these errors were encountered:
The Prisma extension library ZenStack we are building happens to share the same view with wladiston andLiam-Tait’s solution to use the schema as the single source of truth. 🤝
This is how the sample schema should be represented in ZenStack now:
The only differences are:
For the multitenancy issues, we invited a Collection Predict Expression to express it. Here is how it looks now:
If you feel interested, there is a tutorial post I wrote about it:
How to build a collaborative SaaS product using Next.js and ZenStack's access control policy
We would really appreciate it if you could share your opinions by commenting or joining our Discord to help us make ZenStack the right thing to solve your problems.
The text was updated successfully, but these errors were encountered: