Read operation: Searching data for null values


If I want to search for all the documents with poster field (movieDetails collection) not assigned a value, when I put a filter criteria of {poster:null} and it says that there 1252 records matching the criteria. Does it actually mean that when the data is loaded, poster field was originally created with null value. Can we not have the poster field in insertOne or insertMany and still see such records with criteria {poster:null}

Thanks in advance.

Hi @Vijay_81958,

First of all great question :slight_smile:

So before I go ahead and answer your questions, let’s understand the null value in a little detail. If you issue this query :


It will return you all those documents, which has either poster field set to null or those documents which does not have the poster field in it.

If you only want to query for those documents where poster field exists and its value is set to null then you must use the $exists operator. This operator basically checks if a field exists in the document or not. For example :


As you can see in the screenshot, we have 1251 such documents, where poster field exists and it has null value.

Now coming to your question.

Yes, when a field value is set to null it means the values are missing and that’s how it was loaded.

Now coming to your another question.

Yes we can search for such documents by using the $exists operator.

if you have any other issue, feel free to get back to us. Happy Learning :slight_smile:

Shubham Ranjan
Curriculum Support Engineer

1 Like