Hi, im currently making a social media app that have a feature that can display top users ordered by their number of post/s. So in my "Users" collection it already have an attribute of posts which refers to the postId of the post/s they posted. I want to call the users collection and sort it descendingly by its posts total count (which is visible in the appwrite that says 11 items). I also have written a code to call the collection based on posts order descendingly but that doesnt work. Should i have created another attributes which stores an integer for postsCount or is there a way to access attribute 'posts' total items count? What should i change in the code Query.orderDesc()?
Hi 👋 You mensioned your solution doesnt work, what exactly is the issue? Are you getting some error message, or empty list? Or wrong order or values?
its returning error because the query wont even run if i put Query.orderDesc('posts') It returns status 500
i tried console.log() something and it doesnt reach if(!users) throw Error; line
What i actually want to do is query users (in the picture theres only 1 user but later there will be more than 1) based on the attribute 'posts' items count (total result for posts attributes which in the picture says 11) so i can sort them based on their posts posted straight from the query with databases.listDocuments
can i actually do that without creating postCount attribute? or i have to create another attribute for a user to store posts count seperately so i can just orderDesc('postCount')?
Recommended threads
- Use different email hosts for different ...
Hello, I have 2 projects and i want to be able to set up email templates in the projects. Both projects will have different email host configurations. I see ...
- Get team fail in appwrite function
I try to get team of a user inside appwrite function, but i get this error: `AppwriteException: User (role: guests) missing scope (teams.read)` If i try on cl...
- Edit ID of an existing collection
Hi there. Is it possible to edit an ID of an existing collection? Right now it looks impossible from AppWrite cloud at least.