Element Operators
Handle situations where:
Detect the presence or absence of a field.
Different value types in the same field.
📌 $exists
List documents that have a specific field. The value for this operator can be true or false.
db.movieDetails.find({“mpaaRating”: {$exist: true}})
If you use a filter to check the null value, to list documents that either have that field set to null or do not have that field.
📌 $type
List documents that have a field with a specific type of value.
db.movieDetails.find({“viewerRating”: {$type: “int”}})
Last updated
Was this helpful?