Hello everyone,
I am currently a little bit confused on how to define an array of Permissions that I can use in a database.createDocument()
statement. I included a short code snippet to demonstrate my problem:
memberArray.forEach((member) = > {
permissions.push(Permission.read(Role.user(member.userId)));
});
createDocument = await databases.createDocument(
"<database>", "<collection>", ID.unique(), {data}, permissions);```
I've tried several different alternatives including mapping the array directly in the ```createDocument()``` function, or using an array of strings like ```read("user:<id>)```
Nothing seems to work, the error message is always the same: ```Error creating document: [AppwriteException: Permissions must be one of: (any, users, user:<censored>, user:<censored>/unverified, users/unverified)]```
I would be very very grateful if somebody could help me out, because I am starting to feel a little bit dumb 🥲
Btw, it's best to use 3 back ticks with multi-line code. See https://www.markdownguide.org/extended-syntax/#syntax-highlighting
From the docs:
A project user can only grant permissions to a resource that they have. For example, if a user is trying to share a document with a team that they are not a member of, they will encounter a 401 not authorized error. If your app needs users to grant access to teams they're not a member of, you can create Appwrite Functions with a Server SDK to achieve this functionality.
Thank you, I will give it a try.
Recommended threads
- Type Mismatch in AppwriteException
There is a discrepancy in the TypeScript type definitions for AppwriteException. The response property is defined as a string in the type definitions, but in pr...
- What Query's are valid for GetDocument?
Documentation shows that Queries are valid here, but doesn't explain which queries are valid. At first I presumed this to be a bug, but before creating a githu...
- Realtime with multiple connections
I need the Realtime on multiple Collections for diffrent applicational logic. So my question is: Is there a way to have only 1 Websocket connection or do I need...