diff --git a/lib/query/reducers/lib/cleanReducerLeftovers.js b/lib/query/reducers/lib/cleanReducerLeftovers.js index 6f99122..eb89e25 100755 --- a/lib/query/reducers/lib/cleanReducerLeftovers.js +++ b/lib/query/reducers/lib/cleanReducerLeftovers.js @@ -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];