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
- Collections list not showing up when try...
I'm trying to create new relationship attribute but both one way and two way relationship is not showing up collections list to connect with my relationship att...
- I have try to use the appwrite in to the...
Invalid Origin. Register your new client (oailedjdbkhlkakmnnapoonllbnfmfij) as a new Web (Chrome Extension) platform on your project console dashboard
- Weird permission failure
when creating an account I use following methods: ``` Future<void> register(String email, String password, String username) async { final user = await accoun...