MongoDB - $exist and $type operator
$type operator : It matches values based on their BSON type.
e.g. We want to fetch documents from the collection which contains the value of "city" is only null.
db.collection.find( { "city" : { $type : 10 } } ).pretty();
Above query return city with null value.
$exist operator : It matches whether the particular field exist or not in collection.
e.g. We want to fetch documents from the collection which does not contain the "city" column.
db.collection.find( { "city" : { $exists : false } } ).pretty();
Above query return records which have not city column.
0 Comment(s)