Hi, I'm building a gym app tracker.
I want the app to have Routines that contain Sessions and these contain exercises (That is like a starter for the user), and the track info to be on different collections "training day" that is related to "exercise training" and contains an exercise, reps and weight. When I say contains, I refer that have one attribute in relation to another collection.
I have problems with permissions. I understand that the default info (for all users) needs to read document permissions for all users, and then, have turned on the document permission and not collection, but I want users can share routines (Via url or ID), so, I didn't know how to handle that. Also, I would like in the future to add a trainer type of user that can see the training days of the users (Not all, only their trainees), and have a "Routines hub" where trainees can see the routines that the trainer creates and shares. I think that this can be solved with teams, but I don't know how to give teams permission to single documents.
What should be the permissions and is my structure correct?
Thanks in advance and sorry for my English, not native.
Hi, there's several questions here let me break them down.
Sharing exercises with other users:
This can be done a few ways. You can use teams, when sending invites, update their permissions by adding them to the "team" attached to a routine.
You can use an Appwrite Function to add individual permissions to a document or set of documents, and call it from the inviter to add the invitee's ID to document permissions.
You can also generate a long UUID, like a "secret" that isn't exposed to user and is only accessible to Appwrite's Server SDKs. This lets you share a routine by this sercret ID. When a user invites another user, they call and "invite" Appwrite Function, which returns a secret ID that they can pass to another user. When a user accepts the invite, they can call another Appwrite function with the secret ID, the Appwrite function looks up the collection by secret ID, adds their user into the permissions of that routine.
The solution will be some combination of these different approaches.
Also, I would like in the future to add a trainer type of user that can see the training days of the users (Not all, only their trainees)
This is done with teams and roles.
Team for each trainer,
Trainers have the trainer role within teams
Only people from a specific team with role trainer can see training days 🙂
So you'd just update permissions of a specific document with Role.team(TRAINER_ID, TRAINER)
Recommended threads
- Seed db
hello there... is this correct way to seed appwrite
- Query Appwrite
Hello, I have a question regarding Queries in Appwrite. If I have a string "YYYY-MM", how can I query the $createdAt column to match this filter?
- Different appwrite IDs are getting expos...
File_URL_FORMAT= https://cloud.appwrite.io/v1/storage/buckets/[BUCKET_ID]/files/[FILE_ID]/preview?project=[PROJECT_ID] I'm trying to access files in my web app...