- db.product.group({_id: “$category”, count: {$sum:1}})
- db.product.aggregate($sum: {_id: “$category”, count: {$group:1}})
- db.product.aggregate($group: {_id: “$category”, count: {$sum:1}})
- db.product.aggregate($count: {_id: “$category”, count: {$group:1}})
You want to know how many types of items you have in each category. Which query does this?
June 25, 2021June 25, 2021
0 Comment