New to mongodb. I have a question on how to make a mongodb query that involves 2 collections.
Below is my collections.
People _id name email Cars _id model year peopleId
I need to list down all the people records. For each people record, i need to return the number of cars they own.
Involves 2 queries. First query to select all people record. Using a for loop, Second query to count and retrieve the cars records for each people
I am looking for a better solution. A single query that can achieve the above. Any advice appreciated.