Created
March 10, 2015 17:53
-
-
Save stevecass/7084098fb1edf42ba9cd to your computer and use it in GitHub Desktop.
Mongoose group by parent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function doSumByGroup() { | |
var agg = [ | |
{$group: { | |
_id: "$columnObject", | |
total: {$sum: 1} | |
}} | |
]; | |
Snippet.aggregate(agg, function(err, logs){ | |
if (err) { | |
handleErrors(); | |
} else { | |
console.log(logs); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment