Update mount-models.js (#6916)

This is to ensure custom mongoose queries that exclude dynamic zone fields don't fail.

Referring to this issue:
https://github.com/strapi/strapi/issues/6016
This commit is contained in:
atlmtw 2020-07-06 03:35:55 -04:00 committed by GitHub
parent fd3c7699b5
commit 66637e0101
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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,
};
});
if(returned[name]){
const components = returned[name].map(el => {
return {
__component: findComponentByGlobalId(el.kind).uid,
...el.ref,
};
});
returned[name] = components;
returned[name] = components;
}
}
});
},