Merge pull request #145 from Herteby/master

fix issue with adding fields from $filters
This commit is contained in:
Theodor Diaconu 2017-06-13 14:41:38 +03:00 committed by GitHub
commit 9b4ff8ddbc

View file

@ -90,8 +90,11 @@ export default class CollectionNode {
_.each(filters, (value, field) => {
// special handling for the $meta filter and conditional operators
if (!_.contains(['$or', '$nor', '$not', '$and', '$meta'], field)) {
hasAddedAnyField = true;
options.fields[field] = 1;
// if the field or the parent of the field already exists, don't add it
if (!_.has(options.fields, field.split('.')[0])){
hasAddedAnyField = true;
options.fields[field] = 1;
}
}
});