Skip to content

Instantly share code, notes, and snippets.

Created July 21, 2015 18:33
Show Gist options
  • Save anonymous/6254abad506461cd1cb4 to your computer and use it in GitHub Desktop.
Save anonymous/6254abad506461cd1cb4 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' => {$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