Lecture Projections

on using thing query db.movies.find({genre:“Action”,“Adventure”},{title:1}).pretty()
I got the error saying syntax Error:missing property ID.
why is it so?

Look into the $in operator.

Wait a moment… I recall one of the Curriculum Engineers stating that the genres field is a string and not an array in this course. The $in operator I mentioned earlier is mainly for arrays.

Genres has to be one string. Multiple conditions can be achieved but you must specify the field name for each condition.

But same query is being used in video lecture.There, it is working fine.

I do not know the semantic (genre being an array or a string) but the syntax is wrong. Your first argument

is not a valid document. It should be { fieldName : fieldValue , fn2 : fv2 … }. Currently you have 2 values, Action and Adventure. That is why you get missing property ID. An array as fieldValue would be [ “Action” , “Adventure” ]. But if genre or genres, I don’t know if Rahul_14779 or 007_jb has the right spelling, is indeed a string, you will have to dig into regular expression or using $or.

Hi @Rahul_14779,

As others have mentioned in this thread, you have written an incorrect query.

The query used in the course lecture is mentioned below.

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

For more information on this, you can also refer this post.

Hope it helps!

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

Happy Learning :slight_smile:

Shubham Ranjan
Curriculum Support Engineer