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
- 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?
- 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...