Skip to content

Commit

Permalink
Detect array-specific comparison functions
Browse files Browse the repository at this point in the history
  • Loading branch information
louischatriot committed Dec 1, 2013
1 parent bbbc181 commit 8a5372f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,16 +683,15 @@ function matchQueryPart (obj, queryKey, queryValue, treatObjAsValue) {

// Check if the object value is an array
if (util.isArray(objValue) && !treatObjAsValue) {
// Check if we are applying a comparison function to the array itself
// Check if we are using an array-specific comparison function
if (queryValue !== null && typeof queryValue === 'object' && !util.isRegExp(queryValue)) {
keys = Object.keys(queryValue);

keys = Object.keys(queryValue);
for (i = 0; i < keys.length; i += 1) {
if (arrayComparisonFunctions[keys[i]]) { return matchQueryPart(obj, queryKey, queryValue, true); }
}
}

// Else, treat it as an array of { obj, query } where there needs to be at least one match
// If not, treat it as an array of { obj, query } where there needs to be at least one match
for (i = 0; i < objValue.length; i += 1) {
if (matchQueryPart({ k: objValue[i] }, 'k', queryValue)) { return true; } // k here could be any string
}
Expand Down

0 comments on commit 8a5372f

Please sign in to comment.