[Solved] MongoDB query condition including SUM

The $redact operator of the aggregation framework is your best option: db.collection.aggregate([ { “$redact”: { “$cond”: { “if”: { “$lt”: [ { “$add”: [ “$b”, “$c” ] }, 5 ] }, “then”: “$$KEEP”, “else”: “$$PRUNE” } }}, { “$project”: { “_id”: 0, “a”: 1 } } ]) The logical condition is made via $lt on … Read more