OR and Exists can be
used together in MongoDB together along with find Query. OR can be used to
check any of the condition is matched Exists is used to check whether
particular node exists or not.
MongoDB Query :
db.employeeDetails.find({
$or : [ { "employee.number" : null },
{"employee.number":{$exists: false}},
{ "employee.name" : null },
{"employee.name":{$exists: false}}
],
"isActive":true,
"employee.pf":{$exists:true}
}
Above Query retrieves the data from employeeDetails
collection which dosent have employee.number or employee.name and it should be
active and should contain employee.pf value.