MongoDB $exists Operator
The EXISTS operator is a logical operator that allows you to check the existence of data.
MongoDB provides the $exists operator to check the existence of the field in the specified collection.
Syntax of $exists Operator
{ field: { $exists: boolean }}
If $exists is true, it matches the document that contains the field, and if $exists is false, it returns only the documents that do not contain the field.
Example of $exists Operator
Suppose we want to find all students whose class exists.
db.students.find({"class" : {$exists : true}});
