Skip to content

Commit 3b4faaa

Browse files
committed
Merge pull request #799 from carmenlau/query-fix
Fix using query.notContainedIn and query.doesNotMatchQuery at the same time, notContainedIn will be ignored problem
2 parents 187f29c + 6973de7 commit 3b4faaa

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/RestQuery.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,11 @@ RestQuery.prototype.replaceInQuery = function() {
214214
});
215215
}
216216
delete inQueryObject['$inQuery'];
217-
inQueryObject['$in'] = values;
217+
if (Array.isArray(inQueryObject['$in'])) {
218+
inQueryObject['$in'] = inQueryObject['$in'].concat(values);
219+
} else {
220+
inQueryObject['$in'] = values;
221+
}
218222

219223
// Recurse to repeat
220224
return this.replaceInQuery();
@@ -251,7 +255,11 @@ RestQuery.prototype.replaceNotInQuery = function() {
251255
});
252256
}
253257
delete notInQueryObject['$notInQuery'];
254-
notInQueryObject['$nin'] = values;
258+
if (Array.isArray(notInQueryObject['$nin'])) {
259+
notInQueryObject['$nin'] = notInQueryObject['$nin'].concat(values);
260+
} else {
261+
notInQueryObject['$nin'] = values;
262+
}
255263

256264
// Recurse to repeat
257265
return this.replaceNotInQuery();
@@ -290,7 +298,11 @@ RestQuery.prototype.replaceSelect = function() {
290298
values.push(result[selectValue.key]);
291299
}
292300
delete selectObject['$select'];
293-
selectObject['$in'] = values;
301+
if (Array.isArray(selectObject['$in'])) {
302+
selectObject['$in'] = selectObject['$in'].concat(values);
303+
} else {
304+
selectObject['$in'] = values;
305+
}
294306

295307
// Keep replacing $select clauses
296308
return this.replaceSelect();
@@ -329,7 +341,11 @@ RestQuery.prototype.replaceDontSelect = function() {
329341
values.push(result[dontSelectValue.key]);
330342
}
331343
delete dontSelectObject['$dontSelect'];
332-
dontSelectObject['$nin'] = values;
344+
if (Array.isArray(dontSelectObject['$nin'])) {
345+
dontSelectObject['$nin'] = dontSelectObject['$nin'].concat(values);
346+
} else {
347+
dontSelectObject['$nin'] = values;
348+
}
333349

334350
// Keep replacing $dontSelect clauses
335351
return this.replaceDontSelect();

0 commit comments

Comments
 (0)