#[SOLVED] Support for batch operation and data aggregate query
13 messages · Page 1 of 1 (latest)
Or I guess I’ll need to use this as a workaround 😦
Hi there, thank you for your question, let me ask the team for the roadmap
we don't support them yet. appwrite APIs are designed to handle multiple requests concurrently. If you're looking for transactions, here's the issue: https://github.com/appwrite/appwrite/issues/2788.
If you really want to minimize network requests, they can look into using graphql. as for timeline, we are a bit unsure about the exact time of release
Thanks 😄
Hey there 👋
Our REST API does not yet support batch operations. Honestly, I dont think that is on road map yet.
Recently we released GraphQL API, which is by design capable of this. It might be useful to try to use that interface instead of REST API for your specific use case.
Aggregate queries are planned, but I don't think it will be released in next version. But soon, for sure.
In the meantime, you can use total value when running listDocument as alternative to sum. Be aware, this only counts up to 5000 for performance reasons.
Alternativelly you can write your own Appwrite Function and have it run every 15 minutes, and do the aggregation. Then store the result of aggregation into a simple document and read that from frontend.
Hope those solutions can help you build your first project with Appwrite 🤞 If not, I am happy to discuss further to see what the simplest solution for your app might be.
Thank @verbal ether , most of the CRUD flow of my project can be covered with AppWrite, but currently I have some uses case that need data aggregation:
- each users can rate a blog post from 1-5 stars. I want to make a list of blog with most rating or highest average rating.
- this should be trivial using group by + sum or group by + avg, but seems like I need to manually aggregate it by creating a function 🥲
It is the case indeed.
While this might seem frustrating at first, doing this in event-based or CRON function adds a caching layer that helps to improve overall speed of your application at scale.
With that said, it is a requested feature and it is included in our road map. I understand your dislike to this approach.
Trying to calculate the average every time can lead to performance problems since it will be slower and slower to average as the number of ratings grow. I suggest keeping a metadata collection of the total rating and count of ratings. Every time a rating is added, an Appwrite Function can update the total and count. Instead of updating a rating, delete and create a new one. An Appwrite can decrease the total rating and count with the delete and increase the values with the create. Whenever you need to average, you can take the total and divide by the count.
[SOLVED] Support for batch operation and data aggregate query
Hi, do you know if there is an existing Feature request for aggregate queries?
if you can't find a solution by searching #1072905050399191082 please feel free to create a new post