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":{$ne:null}});
Or
db.yourcollection.find({ 'field' : { $exists: true, $ne: null } });
The above-mentioned query will help you find the not null values in the MongoDB collection.
- Best practices for unsubscribing from subscriptions of Observables in Angular
- 10 best practices for creating Angular Application
- How to GroupBy in MongoDB
- How to Join two collections in MongoDB
- How to take screenshot on Android Phone- Samsung, Redmi Note
Happy Coding!!!!
How to Query for “is not null” in MongoDB?