Confusion regarding Ticket: Projection

Hi there, I’m having confusion what does I need to do in this ticket, it says

User Story

"As a user, I'd like to be able to search movies by country and see a list of movie titles. I should be able to specify a comma-separated list of countries to search multiple countries."

Task

Implement the getMoviesByCountry method in src/dao/moviesDAO.js to search movies by country and use projection to return the title field. The _id field will be returned by default.

What I understood from the above statement is that, I have to write a query, which when run displays the list of movie (just their title and _id). Am I right ?
and for the same regard the query I’ve added to my method is as follows:
db.movies.find({}, { title: 1 })
but when I try the unit test, it fails ABSOLUTELY

Hey @Ahsan_72923

This is your query condition. Perhaps search the docs for an query operator that can accomplish this for you.

Yep! The return documents should only display the title and _id

Therefore you just need to figure out the correct query :exclamation:

Which says to:

Find movies matching the “countries” list

Here is a big hint
https://docs.mongodb.com/manual/reference/operator/query-comparison/#comparison-query-operators

Thank you so much @natac13.
Do I need to make use of async or promises etc ?

The projection

will not give you

1 Like

@Ahsan_72923

You are VERY close. So close that I would ask you remove your code, as it is against forum guidelines to post answers. :wink:

But like @steevej-1495 has says your projection is a bit off.

Think about think if doing { field: 1 } will include the field what would the opposite do? Such as { field: 0 }. Then you will realize your sight mistake.

And lastly variables in JavaScript are case sensitive. :wink: :wink:

Hi @Ahsan_72923,

Please look at the following post:

Kanika

2 Likes

@Ahsan_72923

So I have gone ahead and Flagged your posts with answer code for a moderator to delete it!

Please be considerate of the other students and do not post answer code. I know sometimes it is difficult to get help without it. But the community understands that and will do the best they can to help without the code.

I deleted them myself

1 Like