#[SOLVED] Support for batch operation and data aggregate query

13 messages · Page 1 of 1 (latest)

echo hamlet
#

Hi, just want to ask if our current DB support batch operation (inser/upsert) and aggreate query like group by/sum… I don’t see them in our docs yet.

If they’re not available, is there any plan/roadmap about these feature? I really like to use AppWrite for new project, but would need to reconsider if these are not supported 😭

tepid lake
#

Hi there, thank you for your question, let me ask the team for the roadmap

tepid lake
#

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

echo hamlet
#

Thanks 😄

verbal ether
# echo hamlet Hi, just want to ask if our current DB support batch operation (inser/upsert) an...

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.

echo hamlet
#

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 🥲
verbal ether
distant nebula
# echo hamlet Thank <@287294735054274560> , most of the CRUD flow of my project can be covered...

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

low axle
#

Hi, do you know if there is an existing Feature request for aggregate queries?

distant nebula