MongoDB $ where查询,字段名称中带有空格

时间:2018-12-19 02:31:17

标签: mongodb

我正在使用MongoDB发出$ where请求,如下所示:

db.statistiquesClients.find({$where : function() { return (this.postal code == "123 456")}})

如您所见,该字段的邮政编码中有一个空格,因此该请求无效,错误为:

2018-12-18T21:28:57.254-0500 E QUERY    [js] SyntaxError: missing ) in parenthetical @(shell):1:71

我尝试用其他不需要空格的东西替换“邮政编码”,而且效果很好。

1 个答案:

答案 0 :(得分:1)

您可能需要将其更改为this['postal code']