Back

permission role in database

  • 0
  • Databases
  • Cloud
ropi95
5 Jan, 2024, 14:05

Hi team

I have scenarios

  1. I have a collection
  2. User can read all of documents in the collection
  3. User can create documents on the collection
  4. User can edit/update documents that their created (only users own)
  5. User cannot edit other user document

How to setup the roles for this scenarios?

Thank you

TL;DR
User wants to set up permission roles in a database collection. They want users to be able to read and create documents in the collection, but only be able to edit their own documents and not others. Solution: Set collection roles to allow users to create and read, enable document security, and pass a list of permissions that includes Permission.update(Role.user(current_user_id)) and Permission.delete(Role.user(current_user_id)). This will give users the desired access.
Gaurav Solanki
5 Jan, 2024, 14:29

Set collection Roles:- select users and tick create and read, make sure you have enabled document security. And while creating documents pass the list of permissions which contains Permission.update(Role.user(current_user_id)), Permission.delete(Role.user(current_user_id))

ideclon
5 Jan, 2024, 14:49

You don’t actually have to pass the Permissions - the creating user automatically has all permissions on the Document

Gaurav Solanki
5 Jan, 2024, 14:50

@ideclon oh okay

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more