Fixed #304 , options to reducers no longer fail

This commit is contained in:
Theodor Diaconu 2018-10-23 10:40:11 +03:00
parent a070922c2c
commit 863eb5075e

View file

@ -44,8 +44,13 @@ function cleanNestedFields(parts, results, root) {
const snapCacheField = root.snapCaches[parts[0]];
const fieldName = snapCacheField ? snapCacheField : parts[0];
if (parts.length === 1) {
// We add this rule because if by any chance you use your reducer in conjunction with $options, $filters
// They are removed from the body and will no longer be present.
if (!root[fieldName]) {
return;
}
if (parts.length === 1) {
results.forEach(result => {
if (_.isObject(result) && fieldName !== '_id') {
delete result[fieldName];