MongoDB has a number of documents (test events) that look like this:
{ "_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") }
I need to get a result set that looks like this:
[ { "date" : "2014-06-11", "defect_rate" : '.92' }, { "date" : "2014-06-11", "defect_rate" : '.84' }, ]
In other words, I need to get the average level of defect per day. Is it possible?
mongodb mongodb-query aggregation-framework
okoboko
source share