How to populate count number from another schema on Node JS

Viewed 55

I have two schema: Product and Region

Product:

_id,
name,
price,
region_id

Region:

 _id,
 region_name

I want to get region result which includes

_id, 
region_name, 
**the number of products from the region**

Using Region.find() then I got

[ { _id: XXX, region_name: 'ABC' }, ... ]

Should I use populate() or other methods?

My setup: Node JS, Express, Mongoose

Thanks!

0 Answers
Related