Skip to content
Back

Calculating sum of numbers in an Attribute of collection, limit of 25

  • 0
  • Self Hosted
  • Web
Sikandar
5 Aug, 2024, 14:28

By default appwrite limits query to 25 items for better performance, what's the way to calculate sum of numbers in each document. I have a finance demo app with 500 entries, need to sum all numbers but default appwrite query get 25 items, I can put 1000 limit in Query.limit but won't that affect performance?

Is there a way to solve this?

TL;DR
Developers are trying to calculate the sum of numbers in an Attribute of a collection, but the appwrite query limit is causing issues as it only fetches 25 items by default. One solution suggested is to create a function with a trigger to maintain a running total in a separate collection. Another query with a limit of 1000 might affect performance. Aggregation functions are not currently available. **Solution:** The best way currently is to maintain a running total in a separate collection using a trigger function.
Kenny
5 Aug, 2024, 14:29

I don't know if this is the best way of solving it but to do something similar I created a function with a trigger on documents that kept a running total in a different collection

Kenny
5 Aug, 2024, 14:30

Until aggregation functions are added I can't think of another way of doing it

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