Skip to content

Commit

Permalink
Merge pull request #169 from feathersjs/populate-1
Browse files Browse the repository at this point in the history
Thows if ORM found. Issue #144
  • Loading branch information
eddyystop authored May 3, 2017
2 parents 8edf7f2 + a59f11d commit 56eb65a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/services/populate.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,15 @@ export default function (options, ...rest) {
function populateItemArray (options, hook, items, includeSchema, depth) {
// 'items' is an item or an array of items
// 'includeSchema' is like [ { nameAs: 'author', ... }, { nameAs: 'readers', ... } ]


if (items.toJSON || items.toObject) {
throw new errors.BadRequest('Populate requires results to be plain JavaScript objects. (populate)')
}

if (!Array.isArray(items)) {
return populateItem(options, hook, items, includeSchema, depth + 1);
}

return Promise.all(
items.map(item => populateItem(options, hook, item, includeSchema, depth + 1))
);
Expand Down

0 comments on commit 56eb65a

Please sign in to comment.