Skip to content

Commit

Permalink
Fixed populate issue with recursive include
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyystop committed May 20, 2017
1 parent e0d34e0 commit 2c2b5a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
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

0 comments on commit 2c2b5a3

Please sign in to comment.