Template
single collection
multiple collections
mgodatagen
update
indexe
explain
Stage
Database
bson
mgodatagen
[{"firstValue":6,"secondValue":3},{"firstValue":6,"secondValue":5},{"firstValue":6,"secondValue":7}]
Query
db.collection.aggregate({"$match":{"$expr":{$gt:[{"$subtract":["$firstValue","$secondValue"]},2]}}})
Result