Skip to content

Commit 43f014a

Browse files
committed
nits
1 parent 3629c40 commit 43f014a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/Controllers/DatabaseController.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -396,15 +396,14 @@ DatabaseController.prototype.owningIds = function(className, key, relatedIds) {
396396
// equal-to-pointer constraints on relation fields.
397397
// Returns a promise that resolves when query is mutated
398398
DatabaseController.prototype.reduceInRelation = function(className, query, schema) {
399+
399400
// Search for an in-relation or equal-to-relation
400401
// Make it sequential for now, not sure of paralleization side effects
401402
if (query['$or']) {
402403
let ors = query['$or'];
403404
return Promise.all(ors.map((aQuery, index) => {
404405
return this.reduceInRelation(className, aQuery, schema).then((aQuery) => {
405-
if (aQuery) {
406-
query['$or'][index] = aQuery;
407-
}
406+
query['$or'][index] = aQuery;
408407
})
409408
}));
410409
}
@@ -416,7 +415,7 @@ DatabaseController.prototype.reduceInRelation = function(className, query, schem
416415
let t = schema.getExpectedType(className, key);
417416
let match = t ? t.match(/^relation<(.*)>$/) : false;
418417
if (!match) {
419-
return;
418+
return Promise.resolve(query);
420419
}
421420
let relatedClassName = match[1];
422421
let relatedIds;
@@ -455,7 +454,10 @@ DatabaseController.prototype.reduceRelationKeys = function(className, query) {
455454
relatedTo.key,
456455
relatedTo.object.objectId).then((ids) => {
457456
delete query['$relatedTo'];
458-
query['objectId'] = {'$in': ids};
457+
query.objectId = query.objectId || {};
458+
let queryIn = query.objectId['$in'] || [];
459+
queryIn = queryIn.concat(ids);
460+
query['objectId'] = {'$in': queryIn};
459461
return this.reduceRelationKeys(className, query);
460462
});
461463
}

0 commit comments

Comments
 (0)