listing data with aggregate child objects

I have three tables Company and Reviews and users.
I want to get a list of company and the total no of reviews plus the most recent review and the user who gave that review.

please see attached image


Hi Ali,

Here is a doc page that describes most of the calls you need:
To get a list of companies, you need a simple find() call.
In case each review contains a link or name of a company, you’ll need a find() call with a where clause similar to this in order to get reviews for a Company:‘COMPANYNAME’
To get the most recent review, you’ll need a findLast() API call to Reviews table. Then you may load the related user from that Review.

Also this doc page describes different use-cases which I believe will be useful for you:

thanks for the response.

I will check them out, what about the count of the total review.

It would be better to save this number in some column separately, but you also can count the Review objects retrieved for concrete Company (example with whereClause above).