Matching queries with doesNotExist constraint

This commit is contained in:
André Luiz Cardoso
2016-03-29 11:28:45 -03:00
parent 592334756b
commit 3dccd61222
2 changed files with 17 additions and 1 deletions

View File

@@ -206,7 +206,9 @@ function matchesKeyConstraints(object, key, constraints) {
}
break;
case '$exists':
if (typeof object[key] === 'undefined') {
let propertyExists = typeof object[key] !== 'undefined';
let existenceIsRequired = constraints['$exists'];
if ((!propertyExists && existenceIsRequired) || (propertyExists && !existenceIsRequired)) {
return false;
}
break;