#✅ - Best Route for Updating Average Rating in Rating App

6 messages · Page 1 of 1 (latest)

timid citrus
#

I'm a new to amplify and creating a basic rating app in swiftui and looking to get ratings from users and average them together to get the average rating. Is there a way that I can set up my data model so that the average is automatically computed or should I use something like a cloud function to keep the values updated?

candid spruce
#

I would attach a function to a trigger of a table write.
Let me know if you need more info on it

timid citrus
#

Yes, I would love some more info!

candid spruce
#

Here I am incrementing a counter in another table each time I receive a like.

#

The idea is to create a table where you register all ratings.
Each time you receive a rating (or in batch) on this table it will trigger a function and there you can calculate the average rating for a user and write the average rating again in the User table.
The function can be written in python, nodeJS or other languages..

lapis umbraBOT
#

✅ - Best Route for Updating Average Rating in Rating App