When using the ruby driver v1.8.2 I had the following query:
r = col.aggregate([
{ "$match" => { :d => {'$gte' => key_day(from), '$lte' => key_day(to)} } },
{ "$group" => {
_id: { "sid" => "$sid" },
v: {"$sum" => "$v"},
c: {"$sum" => "$c"}}}
]).to_a
In the process of converting the use for driver 2.1.0: I've kept the query intact and it raised no errors, but seems to return the wrong results.
My question is, how should we convert this query properly? Should maybe instead I do:
r = col.find({ :d => {'$gte' => key_day(from), '$lte' => key_day(to)} }).aggregate([
{ "$group" => {
_id: { "sid" => "$sid" },
v: {"$sum" => "$v"},
c: {"$sum" => "$c"}}}
]).to_a
Thanks!