@filiberto You can use the MongoDB $group aggregation operator to group documents from a collection by a specified expression or id:
1 2 3 4 5 6 7 8 |
db.yourCollection.aggregate([ { "$group": { "_id": { key: "$someValue" }, "total": { "$sum": "$someValue" } } } ]) |