diff --git a/lib/model.js b/lib/model.js index 84c3e1c..318cecf 100644 --- a/lib/model.js +++ b/lib/model.js @@ -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 }