当文档中满足某些条件时,我试图得到值的和。 在下面的查询中,我只想在componentId=“ABC”时获取currentValue的和
db.Pointnext_Activities.aggregate( { $project: { _id: 0, componentId:1, currentValue:1 } }, { $group: { _id: "$componentId", total: { $sum: "$currentValue" } } } )