diff --git a/lib/model.js b/lib/model.js index a8bfaa0..88c768f 100644 --- a/lib/model.js +++ b/lib/model.js @@ -13,7 +13,7 @@ var dateToJSON = function () { return { $$date: this.getTime() }; } , lastStepModifierFunctions = {} , comparisonFunctions = {} , logicalOperators = {} - , queryOperatorArray = {} + , arrayComparisonFunctions = {} ; @@ -584,7 +584,7 @@ comparisonFunctions.$exists = function (value, exists) { } }; -queryOperatorArray.$size = function (obj, value) { +arrayComparisonFunctions.$size = function (obj, value) { if (!util.isArray(obj)) { return false; } if (value % 1 !== 0) { throw "$size operator called without an integer"; } @@ -685,8 +685,8 @@ function matchQueryPart (obj, queryKey, queryValue) { firstChars = _.map(keys, function (item) { return item[0]; }); dollarFirstChars = _.filter(firstChars, function (c) { return c === '$'; }); - if (keys.length == 1 && dollarFirstChars.length > 0 && queryOperatorArray[keys[0]]) { - if (!queryOperatorArray[keys[0]](objValue, queryValue[keys[0]])) { return false; } + if (keys.length == 1 && dollarFirstChars.length > 0 && arrayComparisonFunctions[keys[0]]) { + if (!arrayComparisonFunctions[keys[0]](objValue, queryValue[keys[0]])) { return false; } return true; } } diff --git a/test/model.test.js b/test/model.test.js index 64f60d9..b9acbc0 100644 --- a/test/model.test.js +++ b/test/model.test.js @@ -1081,7 +1081,7 @@ describe('Model', function () { }); - describe('Query operator array $size', function () { + describe.only('Query operator array $size', function () { it('Can query on the size of an array field', function () { // Non nested documents