Back

Database setup

  • 0
  • Users
  • Teams
  • Databases
  • Accounts
marcbejar
2 Mar, 2024, 10:38

Hi everybody, I'm new to AppWrite and I need some help designing a database. I'm trying to set up a database where:

  1. There are USERS
  2. A USER can create an ACCOUNT becoming the owner
  3. An ACCOUNT can have multiple EVENTS
  4. An ACCOUNT owner (USER) can give to other users access to the ACCOUNT turning them ACCOUNT managers.
  5. An OWNER can CRUD the account and it's events.
  6. A MANAGER can CRUD account events but only can RU the ACCOUNT he manages.

I've been reading the docs and there is a place where they talk about permissions (https://appwrite.io/docs/advanced/platform/permissions). As I understand, for each ACCOUNT that a logged in user creates it will be granted with .read() .update() .delete() permissions. And then for each manager a user would add I will need to create an endpoint with the updateDocument statement adding the new manager in the .read() and .update() permissions.

Is that alright? I'm used to SQL design systems where I needed to create a table user_accounts[user, account, role] and add and delete account managers there.

Then I have a second question. If a manager creates an event for the Account he manages, on the createDocument statement I need to add permissions for all users that manage this account and the account owner? In the same way, when an account owner creates an event, in the createDocument statement do I have to add permissions for the owner and all the users that manage this account? The way I'm used to do that is, before read, update or delete I check the role in the user_accounts table and decide if this user has enought permissions to perform the action he wants to do.

Thanks in advance. One thing that has amazed me is the incredible appwrite community 😊

TL;DR
Developers are setting up a database using AppWrite: - Users can create an account and have multiple events - Account owners can grant permissions to other users as account managers - Owners can CRUD the account and its events - Managers can CRUD account events but only RU accounts they manage - Question about permissions setup and handling roles like in SQL Solution: Use AppWrite permissions and endpoints to manage permissions for each account/user relationship as needed.
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