Skip to content

Instantly share code, notes, and snippets.

Created July 21, 2015 18:39
Show Gist options
  • Save anonymous/84806a5a4db86bf990f2 to your computer and use it in GitHub Desktop.
Save anonymous/84806a5a4db86bf990f2 to your computer and use it in GitHub Desktop.
in mongo shell, the following works:
db.getCollection('philly_seer').aggregate([
{ $match: {cause_code: 488}},
{ $group: {_id: "$date", total: {$sum: "$call_attempts"} } },
])
but in ruby, this will not work
match = { '$match' => {'cause_code' => 488}}
group = { '$group' => {'_id' => "$date", 'totalAmount' => {$sum => "$call_attempts"} } }
coll.aggregate([match, group]) # returns an empty array.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment