M220N - Ticket: Projection

So when trying to apply the filter to get the countries that are entered separated by comma, I understand that I need to essentially compare the array created by the user input and the array of countries in the countries field of the document and return documents that have countries in the intersection. What I am confused on is, initially I was trying to use:

var countryFilter = Builders < Movie > .Filter.In(c => c.countries, countries)

where the second countries entered is the array created by the user in put and the first should be a lambda to the document array. At least to my understanding, however, it doesn’t seem to work. What DOES work is:

var countryFilter = Builders < Movie > .Filter.In(“countries”, countries)

This does not produce an error, however, it does not produce any results either. My biggest question is what the difference is between “countries” and c => c.countries. It is my understanding that in this context they should produce the same result.

I’ve included my full code snippet below for reference:

Solved: Turns out I didn’t have a problem at all, the display function for the mflix page to search by countries just isn’t implemented yet. So I just needed to run the unit tests and use the status page instead of trying to actually search movies by country in the app…

Make sure to run those unit tests first

1 Like