假设我将文档插入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
}
我知道$不推荐哪里,但如果我必须使用它,有什么方法可以实现这一目标吗?提前谢谢。