Open Source - mongoDB, nodeJS , PHP and mysql
Wednesday, 2 April 2014
find the sum in mongoDB using nodejs
db.collectionName.aggregate([{$match: {whereColumn: value}}, {$group: {_id: "$fieldToGroup", "total_budget": {$sum: "$column.amount"}}}], function(err, sum) {
console.log(sum[0].total_budget);
});
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment