Ticket: Projections test 1


I have some issue with JS basics, but really interested in it.
I was taking course from JS.
NOW this unit test and async/await hard for me.
Can you help me a little?

Here is my code:

static async getMoviesByCountry(countries) {
    let cursor
    try {
      let filter = "Kosovo"
      let result2 = await movies.findOne(
      { countries: filter },
      { projection: { _id: 1, title: 1 } },

    } catch (e) {
      // I comment next line couse drop error every time...
      //console.error(`Unable to issue find command, ${e}`)
      return []
    // I comment next line couse drop error every time...
    //return cursor.toArray()


The console loged this for the result2 variable:


    { _id: 573a13eff29313caabdd7dca, title: 'Sworn Virgin' }

What should i do for satisfy the test?

Which variable or return parameter should i use to transfer my result2 in?

Thank you for your prompt help!

Hi @Ur_Sonka, welcome to the community.
Please note that the lab asks you to:

// 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.

Therefore, the query that you have written is wrong.
You need to update it to so that you will find all the movies that belong to the countries that exist in the countries array.
Please take a look at the documentation for comparison operators and use the appropriate operator in your query’s filter.

I hope that helps.

In case you have any doubts, please feel free to reach out to us.

Thanks and Regards.
Sourabh Bagrecha,
Curriculum Services Engineer

It helps i’ve done. Thank you! :blush:

1 Like