Skip to content

Commit

Permalink
Update mount-models.js (strapi#6916)
Browse files Browse the repository at this point in the history
This is to ensure custom mongoose queries that exclude dynamic zone fields don't fail.

Referring to this issue:
strapi#6016

Signed-off-by: Gil Fernandes <gil.fernandes@onepointltd.com>
  • Loading branch information
atlmtw authored and onepointconsulting committed Aug 13, 2020
1 parent ffb2361 commit a1bef7f
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/strapi-connector-mongoose/lib/mount-models.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,16 @@ module.exports = ({ models, target }, ctx) => {
}

if (type === 'dynamiczone') {
const components = returned[name].map(el => {
return {
__component: findComponentByGlobalId(el.kind).uid,
...el.ref,
};
});

returned[name] = components;
if(returned[name]){
const components = returned[name].map(el => {
return {
__component: findComponentByGlobalId(el.kind).uid,
...el.ref,
};
});

returned[name] = components;
}
}
});
},
Expand Down

0 comments on commit a1bef7f

Please sign in to comment.