You can explicitly query with the $and
operator as:
var family_id = Meteor.user().profile.family_id,
myMembers = Meteor.users.find({
"$and": [
{ "profile.family_id": family_id },
{
"$or": [
{ "isDeleted": false },
{ "isDeleted": null } /* or { "isDeleted": { "$exists": false } } */
]
}
]
});
or implicitly by specifying comma-separated expressions:
var family_id = Meteor.user().profile.family_id,
myMembers = Meteor.users.find({
"profile.family_id": family_id,
"$or": [
{ "isDeleted": false },
{ "isDeleted": null } /* or { "isDeleted": { "$exists": false } } */
]
});
Note: To check whether a field exists, you can use the $exists
operator as { "isDeleted": { "$exists": false } }
since the { isDeleted : null }
query matches documents that either contain the isDeleted
field whose value is null or that do not contain the isDeleted
field.