How to Query for “is not null” in MongoDB?

Query for is not null in MongoDB

Query for “is not null” in MongoDB: We have a mongo collection that contains a field with null, blanks or some value. We now need to find all the records, where the value of that field is not null. We can use the below-mentioned query to find out all the not null records in the document.

Query to find out not null in MongoDB



db.yourcollection.find({ 'field' : { $exists: true, $ne: null } });

The above-mentioned query will help you find the not null values in the MongoDB collection.

Happy Coding!!!!

How to Query for “is not null” in MongoDB?

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top