Skip to content

Commit

Permalink
added $elemMatch query operator support
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsos1os committed Jan 30, 2016
1 parent f3af2bf commit dc4c979
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,20 @@ comparisonFunctions.$size = function (obj, value) {

return (obj.length == value);
};
comparisonFunctions.$elemMatch = function(obj,value){
if (!util.isArray(obj)) { return false; }
var i = obj.length;
var result = false; // Initialize result
while(i--){
if (match(obj[i],value)){ // If match for array element, return true
result = true;
break;
}
}
return result;
};
arrayComparisonFunctions.$size = true;
arrayComparisonFunctions.$elemMatch = true;


/**
Expand Down

0 comments on commit dc4c979

Please sign in to comment.