First of all, I’d like to say that I’m learning a lot from this course.
I have a question that is related to the use of try/catch and query.
In the previous ticket, the one that we need to implement the getMoviesByCountry method we use a try/catch approach.
let results
try {
results = await movies.find(
{countries : {in: countries}}, {projection: {title: 1}} ); console.log(results) } catch (e) { console.error(`Unable to issue find command, {e}`)
return
}
return results.toArray()
However in this ticket we use a simple query.
const searchGenre = Array.isArray(genre) ? genre : genre.split(", ")
const query = {genres: {$in: searchGenre}}
const project = {}
const sort = DEFAULT_SORT
return { query, project, sort }
Why is that?