Back

Appwrite Query GROUP BY/SUM/COUNT

  • 0
  • Self Hosted
  • Flutter
showmore
4 Apr, 2023, 08:52

I am learning appwrite, Can you help me, Its possible to Query Group by and Sum or count

TypeScript
await databases!.listDocuments(
        databaseId: "***************",
        collectionId: "***************",
        queries: [
          Query.equal("uid", uid),
          Query.Sum..
        ],
TL;DR
Currently, grouping by sum or count is not available in Appwrite. However, one workaround is to write a custom function that stores the sum or count in a separate database table. Then, you can use query methods on this stored data. For example, you can create a function to store the count and then use query.equal to find elements with a count of 5. The Appwrite team plans to work on adding this feature in the future.
joeyouss
4 Apr, 2023, 09:10

hi 👋

joeyouss
4 Apr, 2023, 09:10

So, your question is if querying by group or sum or count is allowed in Appwrite?

joeyouss
4 Apr, 2023, 09:10

Also, amazing to hear you learning about Appwrite - how are you finding it so far?

joeyouss
4 Apr, 2023, 09:24

So, grouping by sum or count is not available at the moment - however this is a spot we plan on working on this year.

But a workaround could be writing your own function which stores in a database the sum and count (differently) and then they can run the query methods suitable for them. say for example, we want to check the elements who's count is 5 (means they repeat 5 times in database) - for this we would create a function that stores count and then we can use query.equal on their count parameter - if its 5, we get the return

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more