Ticket: Projection getMoviesByCountry issue - RESOLVED

I’m unable to pass the tests and not sure what it is I’m doing wrong.

I tried to take out the limit but it did not resolve my issue.

My code bellow:

static async getMoviesByCountry(countries) {
Ticket: Projection

Write a query that matches movies with the countries in the "countries"
list, but only returns the title and _id of each movie.

Remember that in MongoDB, the $in operator can be used with a list to
match one or more values of a specific field.

let cursor
try {
  // TODO Ticket: Projection
  // Find movies matching the "countries" list, but only return the title
  // and _id. Do not put a limit in your own implementation, the limit
  // here is only included to avoid sending 46000 documents down the
  // wire.

  cursor = await movies
    .find({ country: { $in: countries } }, { projection: { title: 1 } })
} catch (e) {
  console.error(`Unable to issue find command, ${e}`)
  return []

return cursor.toArray()



I found my main error which was searching for country rather than countries.
Also, I did need to take out the limit to pass the tests.

My updated code:
cursor = await movies.find(
countries: { $in: countries },
projection: { title: 1, id: 1 },