How to group data by dates? I have some docs in mongo that looks something like this: yes i have added my actuall mongo doc and my code too
{
"_id" : ObjectId("58c0e32161ccc654160b776a"),
"consumer_id" : ObjectId("579f03069b49a0840409df83"),
"user_id" : "579f034c9b49a0840409df85",
"values" : [
{
"date" : "2017/2/9",
"point" : 1
},
{
"date" : "2017/2/10",
"point" : -1
},
{
"date" : "2017/2/11",
"point" : -1
}
]
}
{
"_id" : ObjectId("58c0e3db61ccc654160b776b"),
"consumer_id" : ObjectId("579f03069b49a0840409df83"),
"user_id" : "579ef6f5a15b0eac1332034e",
"values" : [
{
"date" : "2017/2/9",
"point" : 1
},
{
"date" : "2017/2/10",
"point" : 1
},
{
"date" : "2017/2/11",
"point" : -1
}
]
}
I'd like to be able to count the no of points by date my code is like this
var array = [];
var array2 = [];
db.coll.find({}).toArray(function(err, result) {
result.map(function(data) {
array.push(data.values)
})