0
如果我有收集了一些文件,這些文件的格式如下:如何比較數學表達式中蒙戈
{
"_id" : ObjectId("53202e1d78166396592cf805"),
"a" : 4,
"b" : 2,
"c" : 4,
"d" : 3
}
如何選擇與此條件的文件:
db.stat.find({」一個」 + 'b'> 'C' + 'd'})
可能,使用聚合,但隨後什麼條件在節 「macth」:
db.stat.aggregate([
{$project : {
_id : '$_id',
'ab' : { '$add' : [ '$a', '$b' ] },
'cd' : { '$add' : [ '$c', '$d' ] }
}},
{$match: {???}}
]);
感興趣的解決方案沒有mapReduce和沒有人工方法比較值爲零($subtract:["$ab", "$cd"] > 0
)。
在你的比賽中,你爲什麼不使用http://docs.mongodb.org/manual/reference/operator/aggregation/cmp/來查看它是什麼方式?但是,那幾乎就像減法 – Sammaye
@NeilLunn是啊你的答案在這裏是正確的,不知道爲什麼我寫了我所做的 – Sammaye