Renames queryOperatorArray

pull/2/head
Louis Chatriot 11 years ago
parent f3df032887
commit 5c2e44ea69
  1. 8
      lib/model.js
  2. 2
      test/model.test.js

@ -13,7 +13,7 @@ var dateToJSON = function () { return { $$date: this.getTime() }; }
, lastStepModifierFunctions = {} , lastStepModifierFunctions = {}
, comparisonFunctions = {} , comparisonFunctions = {}
, logicalOperators = {} , 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 (!util.isArray(obj)) { return false; }
if (value % 1 !== 0) { throw "$size operator called without an integer"; } 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]; }); firstChars = _.map(keys, function (item) { return item[0]; });
dollarFirstChars = _.filter(firstChars, function (c) { return c === '$'; }); dollarFirstChars = _.filter(firstChars, function (c) { return c === '$'; });
if (keys.length == 1 && dollarFirstChars.length > 0 && queryOperatorArray[keys[0]]) { if (keys.length == 1 && dollarFirstChars.length > 0 && arrayComparisonFunctions[keys[0]]) {
if (!queryOperatorArray[keys[0]](objValue, queryValue[keys[0]])) { return false; } if (!arrayComparisonFunctions[keys[0]](objValue, queryValue[keys[0]])) { return false; }
return true; return true;
} }
} }

@ -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 () { it('Can query on the size of an array field', function () {
// Non nested documents // Non nested documents

Loading…
Cancel
Save