This is my document schema:
{
"_id" : ObjectId("5203c8b91afdd7160c6ecfd3"),
"answer_calls" : "",
"start" : "10:00",
"end" : "10:30",
"VDN_name" : "SP_SYNDICATED_7",
"total_calls" : "1",
"date" : "01/07/2013",
"abandoned_calls" : "",
"voicemail_calls" : ""
}
I try, by aggregation-framework, this:
> dir.aggregate(
[
{ $group:
{_id: {fecha:"$date", hora: "$start"},
llamadas :{ $sum:"$total_calls"},
abandoned: {$sum:"$abandoned_calls"},
mail: {$sum:"$voicemail_calls"}
}
},
{ $sort: {fecha:1,hora:1} }
] )
And here is an example of the result:
{
"_id" : {
"fecha" : "16/07/2013",
"hora" : "18:30"
},
"llamadas" : 0,
"abandoned" : 0,
"mail" : 0
}
The problem is that it does not $sum and neither $sort
Does anybody know why?
The solution was:
dir.aggregate(
[
{ $group:
{_id: {fecha:"$date", hora: "$start"},
llamadas :{$sum:"$total_calls"},
answer :{ $sum:"$answer_calls"},
abandoned: {$sum:"$abandoned_calls"},
mail: {$sum:"$voicemail_calls"} }
},
{ $sort:
{'_id.fecha':1 , '_id.hora':1} }
] )
Thank you again to Sammaye and JohnnyHK
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With