Array query working unexpectedly

Hi there, I’m working through Lesson 1 Lab - $match and I got stuck on querying all movies that aren’t Crime or Horror movies.

I’m not asking for a solution, but rather if someone could explain why my query is wrong. This is what I wrote:

{ “genres”: { $not: { $in: [“Horror”, “Crime”] } } }

The thing that confuses me is that rather that failing, it outputs all movies that have an empty “genres” array

If the array is empty, then $in:WhatEver is false and then $not:false is true.

1 Like

Ok, that makes sense, but there should also be arrays that contain anything BUT ‘Crime’ and ‘Horror’ and I’m only getting empty arrays as a match

Please post the whole query. You must have another clause that eliminate what you think you should have.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.