我在MongoDB中有一系列文档(判断事件),如下所示:
{
"_id" : ObjectId("5397a78ab87523acb46f56"),
"inspector_id" : ObjectId("5397997a02b8751dc5a5e8b1"),
"status" : 'defect',
"utc_timestamp" : ISODate("2014-06-11T00:49:14.109Z")
}
{
"_id" : ObjectId("5397a78ab87523acb46f57"),
"inspector_id" : ObjectId("5397997a02b8751dc5a5e8b2"),
"status" : 'ok',
"utc_timestamp" : ISODate("2014-06-11T00:49:14.109Z")
}
我需要得到这样一个结果集:
[
{
"date" : "2014-06-11",
"defect_rate" : '.92'
},
{
"date" : "2014-06-11",
"defect_rate" : '.84'
},
]
换句话说,我需要得到每天的平均缺陷率.这可能吗?