Skip to content

Instantly share code, notes, and snippets.

@jtbonhomme
Created December 6, 2016 17:19
Show Gist options
  • Save jtbonhomme/9ebcc5fcf92e3a3a6e4067294ab041d0 to your computer and use it in GitHub Desktop.
Save jtbonhomme/9ebcc5fcf92e3a3a6e4067294ab041d0 to your computer and use it in GitHub Desktop.
aggregate mongodb
db.g5t.aggregate([{$project: { msd:true, actKey:true }},{$group:{_id: {msd:"$msd", actKey: "$actKey"}, total: {$sum : 1}}},{$group:{_id: "$_id.msd", ackKeys: {$push: {actKey: "$_id.actKey", quantity: "$total"}}}},{$out: "g5tend2"}], {allowDiskUse:true});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment