help me fix it as i'm trying to get specifc last document of specific user... maybe it's wrong direction
response = await database.list_documents(database_id, collection_id, [ Query.equal("$permissions.read", [f"user:{user_id}"]),Query.limit(1), Query.order_desc('$createdAt')])
Got - Error getting the latest document: Invalid query: Attribute not found in schema: $permissions ....
Uh ya, you can't query on permissions like that
how can i? if i have collection that serve several users- isn't it the best way to filter on the server side per user?
The walkaround i did is to add attribute of the user_id for the collection, which looks to me pretty ugly practice
Sure but you can't do a query that isn't supported...
Yes, that is one approach. Otherwise, I often use the user id for the document id
So to put a prefix in the document id that is the userid? and then how to query that?
No use it as the document id.
For example, I have one app where I have a collection of user documents. Each user should have 1 document. So, I use the user's id for that document id when I create the document in the users collection. Then, when I need to fetch the user's document, I use the get document call
but if i got more?
you suggest to store all the "documents" in one document? the problem is that there is limit on that array document
I think it is a feature suggestion to add the query for permission, that will make the life much easier. Don't you think?
So a user will have multiple? Will they have access to others?
Feel free to add a 👍 to https://github.com/appwrite/appwrite/issues/5169
No - they don't have permission - it's document level permission
The real usecase happenning is when the server is adding data to users..and not the users themselfs..
Ya having an attribute for the user id is probably the best approach
Recommended threads
- Error connecting Github
I have followed the documentation online for setting up VCS and cannot get my Github to properly connect in Functions. When I press the "Connect to Github" I am...
- delete cancelled site deployment
I would like to remove a cancelled site deployment, but the site menu shows only "Redeploy".
- Couldnt not do appwrite push tables
Not sure why i am not able to create my tables