As of now, Appwrite's doesn't support any aggregation function, you can follow (and upvote it
) this issue to track it.
As for your solution, the best would be to create an atomic counter fields for each of the questions/answers/votable posts.
Like so, for example, in case of posts.
- Create collection named
posts with this attributes.
- Create collection named
votes with this attributes.
- Then create a function and make it to be triggered on any change to the
votes collection, so when the a documents is being add increase the value of posts.votes attribute, and when it got deleted decrease it.
This way you can have counters without having the need to query all the documents every time.