Skip to content

Commit

Permalink
fix: add $and incursive process
Browse files Browse the repository at this point in the history
  • Loading branch information
Kingtous committed Oct 23, 2021
1 parent ab855a3 commit 6c66d77
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/Controllers/DatabaseController.js
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,18 @@ class DatabaseController {
return Promise.resolve(query);
});
}
if (query['$and']) {
const ors = query['$and'];
return Promise.all(
ors.map((aQuery, index) => {
return this.reduceInRelation(className, aQuery, schema).then(aQuery => {
query['$and'][index] = aQuery;
});
})
).then(() => {
return Promise.resolve(query);
});
}

const promises = Object.keys(query).map(key => {
const t = schema.getExpectedType(className, key);
Expand Down Expand Up @@ -1049,7 +1061,13 @@ class DatabaseController {
})
);
}

if (query['$and']) {
return Promise.all(
query['$or'].map(aQuery => {
return this.reduceRelationKeys(className, aQuery, queryOptions);
})
);
}
var relatedTo = query['$relatedTo'];
if (relatedTo) {
return this.relatedIds(
Expand Down

0 comments on commit 6c66d77

Please sign in to comment.