Start a new topic

How to solve this?

Even tough I'm working with Kinveys HTML/Javascript API my question is of general purpose:

Let's say there is a collection called PRODUCTS holding a list of simple products with name, description, type, price, etc.

Users now can rate these products within a range from 1 (worst) to 5 (best). All the user ratings are stored in collection RATINGS. 

As you can think there is a 1:many relation from a PRODUCTS to RATINGS (a product can be have one or many ratings). 

Requirement:Whenever a user requests a product list from PRODUCTS collection he also should see the average rating of each product in that list.

In a relational database this an easy task but I don't know what's the best way to do that in Kinvey? I'm aware there are grouping and average functions in Kinvey API. So the math part is not the point. I wonder how I should "join" the data to get the average rating of each request product. Consider there could be like 1'000 ratings for a single product and a user may request 100 distinct products. 

I'm open for any idea to solve this in a proper and effective/fast way.


Login or Signup to post a comment