检查一个密钥是否大于mongodb中的另一个密钥

时间:2014-04-24 12:25:58

标签: mongodb

我想将一个键值与mongodb中的另一个键值进行比较。任何人都可以帮我解决这个问题。

示例:

{
"_id":"xxxxx",
"game":"xxx",
"score":100,
"hi-score":200
}

我想检查分数是否高于hi-score

1 个答案:

答案 0 :(得分:-1)

使用http://docs.mongodb.org/manual/reference/operator/query/where/

尝试以下查询
db.collection.find( { $where: "this.score > this.hi-score" } );

另外,请阅读链接中提供的警告部分。

PS:我没试过这个

相关问题