我有这个样本MongoDB数据:
{"FirstName": "Bruce", "LastName": "Wayne",
"Email": "bwayne@Wayneenterprises.com"}
{"FirstName": "Lucius", "LastName": "Fox",
"Email": "lfox@Wayneenterprises.com"}
{"FirstName": "Dick", "LastName": "Grayson",
"Email": "dgrayson@Wayneenterprises.com"}
和我想要得到的并找到所有文档的计数
可以这样写:
db.col.aggregate([ {$match:{ "Bed Grade":4}} , { $group: {_id:{h:"$Hospital_code" ,d:"$Department" } , cnt:{$sum:1}} } , {$match:{cnt:{$gt:5}}} ])