当字段的键是数字时,如何在mongodb中使用WHERE子句

时间:2014-03-14 21:53:00

标签: mongodb shell where

假设我将文档插入mongo,如下所示:

db.test.insert({1 : { 2 : "some value"}, 3 : { 4 :"some other value"}});

如何使用$ where子句匹配此文档?我尝试使用以下内容:

db.test.find({"$where" : "this.1.2 == this.3.4"});

但我最终收到此错误消息。

    error: {
    "$err" : "JavaScript execution failed: SyntaxError: Unexpected number",
    "code" : 16722
    }

我知道$不推荐哪里,但如果我必须使用它,有什么方法可以实现这一目标吗?提前谢谢。

0 个答案:

没有答案