If I have collection with some documents, which have the form:
{
"_id" : ObjectId("53202e1d78166396592cf805"),
"a" : 4,
"b" : 2,
"c" : 4,
"d" : 3
}
How to select documents with this condition:
db.stat.find({'a' + 'b' > 'c' + 'd'})
Possible, use aggregation, but then what condition in section "macth":
db.stat.aggregate([
{$project : {
_id : '$_id',
'ab' : { '$add' : [ '$a', '$b' ] },
'cd' : { '$add' : [ '$c', '$d' ] }
}},
{$match: {???}}
]);
Interested the solution without mapReduce and without artificial methods of comparing the value to zero ($subtract:["$ab", "$cd"] > 0
).