1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| db.getCollection('cart').aggregate([ { $match: { "company_id": 2057013 } }, { $group: { _id: { "self_company_id": "$self_company_id", "user_id": "$user_id", }, total: { $sum: 1 } } }, { $sort: {total: -1} } ])
|