Improved match aggregate (#4495)

* Improve aggregate queries

* using pg-promise query formatting

* match multiple comparison

* $or and complex match
This commit is contained in:
Diamond Lewis
2018-01-20 08:00:36 -06:00
committed by GitHub
parent 33890bbbfc
commit 64e568d000
3 changed files with 206 additions and 28 deletions

View File

@@ -524,6 +524,20 @@ export class MongoStorageAdapter implements StorageAdapter {
stage.$group._id = `$_p_${field}`;
}
}
if (stage.$match) {
for (const field in stage.$match) {
if (schema.fields[field] && schema.fields[field].type === 'Pointer') {
const transformMatch = { [`_p_${field}`] : `${className}$${stage.$match[field]}` };
stage.$match = transformMatch;
}
if (field === 'objectId') {
const transformMatch = Object.assign({}, stage.$match);
transformMatch._id = stage.$match[field];
delete transformMatch.objectId;
stage.$match = transformMatch;
}
}
}
return stage;
});
readPreference = this._parseReadPreference(readPreference);