query in mongo Shell gives SyntaxError: missing :

2020-03-02 07:49发布

db.movieDetails.find(
  { year: 2013, imdb.rating: Pg-13, award.wins: 0 },
  { title: 1, _id: 0 }
).pretty();

The mongo shell returns this error

2016-08-13T09:08:00.648+0200 E QUERY [thread1] SyntaxError: missing : after property id @(shell):1:60

Why? Thank you in advance!

1条回答
趁早两清
2楼-- · 2020-03-02 08:49

If your query includes inner documents, then use quotes for them. Also, use quotes for querying String values

db.movieDetails.find(
  { year: 2013, "imdb.rating": "Pg-13", "award.wins": 0 },
  { title: 1, _id: 0 }
).pretty();
查看更多
登录 后发表回答