Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 如何在文档中的相同字段之间使用mongodb中的$where_Node.js_Mongodb - Fatal编程技术网

Node.js 如何在文档中的相同字段之间使用mongodb中的$where

Node.js 如何在文档中的相同字段之间使用mongodb中的$where,node.js,mongodb,Node.js,Mongodb,我的代码与 collSession.find({$where:“this.Prices[0].PGroup\u strCode==this.grpCode” 在node.js和mongodb版本中使用:2.4.2 事实上,数据是存在的,但它没有给出任何结果。 我哪里出错了?架构是什么样子的?你确定这个.Prices[0].PGroup\u strCode的值是你期望的值吗?是的。我使用的是mongodb本机驱动程序。在同一个函数中,如果我在同一个集合中放置其他没有数组的字段,如(this.ses

我的代码与

collSession.find({$where:“this.Prices[0].PGroup\u strCode==this.grpCode”

在node.js和mongodb版本中使用:2.4.2 事实上,数据是存在的,但它没有给出任何结果。
我哪里出错了?

架构是什么样子的?你确定这个.Prices[0].PGroup\u strCode的值是你期望的值吗?是的。我使用的是mongodb本机驱动程序。在同一个函数中,如果我在同一个集合中放置其他没有数组的字段,如(this.session==“shan”)它的作用是编辑您的问题,以包括其中一个文档在Json中的外观。如果您需要使用$where,那么您的架构设计可能很差。不建议使用$where,如果您将文档设计为与预期用途相匹配(即您将针对它们运行的查询),则不应该使用它。