db.restaurants.aggregate(
[
{ $match: { "borough": "Queens", "cuisine": "Brazilian" } },
{ $group: { "_id": "$address.zipcode" , "count": { $sum: 1 } } }
]
);
高洛峰2017-04-28 09:06:16
http://docs.mongodb.org/manual/reference/operator/aggregation/sum/
按表达式值求和 1代表1个