Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed populate issue with recursive include #191

Merged
merged 1 commit into from
May 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/services/populate.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ function populateAddChild (options, hook, parentItem, childSchema, depth) {
result = result[0];
}

return childSchema.include
return (childSchema.include && result)
? populateItemArray(options, hook, result, childSchema.include, depth) : result;
})
.then(items => ({ nameAs, items }));
Expand Down
10 changes: 9 additions & 1 deletion test/helpers/get-init-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,15 @@ module.exports = function (name) {
author: '167asdf3689348sdad7312131s',
readers: ['as61389dadhga62343hads6712', '167asdf3689348sdad7312131s'],
createdAt: 1480793101559
}
},
'4': {
id: 4,
title: 'Post 4',
content: 'Lorem ipsum dolor sit amet 5',
author: '167asdf3689348sdad7312131s',
readers: [],
createdAt: 1480793101559
}
};

const recommendation = {
Expand Down