mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Move $exists to the new model
Fixes two incompatibilities:
- {$exists: false} did the wrong logic when there were multiple branches
(we (poorly) special-cased $not and $nin but not this negative case)
- No longer require the argument to $exists to be a boolean;
{$exists: 0} and {$exists: 1} should work, eg
This commit is contained in:
@@ -433,6 +433,15 @@ Tinytest.add("minimongo - selector_compiler", function (test) {
|
||||
nomatch({a: {$exists: false}}, {a: [1]});
|
||||
match({a: {$exists: false}}, {b: [1]});
|
||||
|
||||
match({a: {$exists: 1}}, {a: 5});
|
||||
match({a: {$exists: 0}}, {b: 5});
|
||||
|
||||
nomatch({'a.x':{$exists: false}}, {a: [{}, {x: 5}]});
|
||||
match({'a.x':{$exists: true}}, {a: [{}, {x: 5}]});
|
||||
match({'a.x':{$exists: true}}, {a: [{}, {x: 5}]});
|
||||
match({'a.x':{$exists: true}}, {a: {x: []}});
|
||||
match({'a.x':{$exists: true}}, {a: {x: null}});
|
||||
|
||||
// $mod
|
||||
match({a: {$mod: [10, 1]}}, {a: 11});
|
||||
nomatch({a: {$mod: [10, 1]}}, {a: 12});
|
||||
|
||||
@@ -258,6 +258,12 @@ var VALUE_OPERATORS = {
|
||||
$nin: function (operand) {
|
||||
return invertBranchedSelector(convertElementSelectorToBranchedSelector(
|
||||
ELEMENT_OPERATORS.$in(operand)));
|
||||
},
|
||||
$exists: function (operand) {
|
||||
var exists = convertElementSelectorToBranchedSelector(function (value) {
|
||||
return value !== undefined;
|
||||
});
|
||||
return operand ? exists : invertBranchedSelector(exists);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1038,7 +1044,6 @@ var andCompiledDocumentSelectors = function (selectors) {
|
||||
|
||||
|
||||
// Remaining to update:
|
||||
// - $exists
|
||||
// - $type
|
||||
// - $regex/$option
|
||||
// - $all
|
||||
|
||||
Reference in New Issue
Block a user