Exception error when running search command with projections

trying to run search command with projections as described the the Projections lecture ,getting the following exception

MongoDB Enterprise Cluster0-shard-0:PRIMARY> db.movies.find({“genre”: “Action, Adventure”}), {title:1})
2019-11-05T14:22:13.049+0200 E QUERY [js] uncaught exception: SyntaxError: unexpected token: ‘)’ :
@(shell):1:57

The error message says

It means you have a ) at an unexpected place. The command find ends with the first ) which is probably unexpected since you have a second parameter. However the message tells you it is the last one (at line 1 column 57) that is unexpected. But a parse is dump. As a human we understand your intent is to project the title. That’s why I wrote that the first is unexpected.

Hi @shlomi_06088,

As @steevej-1495 mentioned, you have an extra closing round bracket “)” in your query.

The correct query would be :

db.movies.find({"genre": "Action, Adventure"}, {title:1})

Hope it helps!

If you have any other questions, then please feel free to get back to us.

Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer

As a side note, is genre not an array?

Hi @007_jb,

No, it’s a string field in the video.movies collection.

Hope it helps!

Thanks,
Shubham Ranjan
Curriculum Support Engineer

Thanks for the info ,query is working now .