MongoDB - 语法错误:非法字符

Kam*_*rov 2 database mongodb

我正在尝试在 MongoDB 中运行一个总和查询,该查询计算三个州的所有邮政编码,但继续遇到这个问题:

SyntaxError: illegal character
Run Code Online (Sandbox Code Playgroud)

这是我的数据示例:

{ "_id" : "80002", "city" : "ARVADA", "loc" : [ -105.098402, 39.794533 ], "pop" : 12065, "state" : "CO" }
{ "_id" : "80003", "city" : "ARVADA", "loc" : [ -105.065549, 39.828572 ], "pop" : 32980, "state" : "CO" }
Run Code Online (Sandbox Code Playgroud)

这是我的查询:

db.population.aggregate([ 
{ $match: { $and: [ {“state”:”CA”}, { “state”:”AZ”}, {“state”:”NM”}] } },
{$group : {_id: null, count:{$sum:1}}}
])
Run Code Online (Sandbox Code Playgroud)

我正在尝试计算三个州的所有邮政编码,所以这是一个很好的查询吗?如果不是,我该怎么做?

任何帮助表示赞赏!

小智 9

如果您使用的是 CLI,请尝试倾斜 (`) 而不是双引号 (")。试一试。快乐编码!!!