mirror of
https://github.com/strapi/strapi.git
synced 2025-11-23 05:30:11 +00:00
Merge pull request #2693 from strapi/fix-image-populate
Fix image populate
This commit is contained in:
commit
98717a1ccf
@ -160,6 +160,28 @@ module.exports = function (strapi) {
|
|||||||
} else {
|
} else {
|
||||||
this._mongooseOptions.populate[association.alias].path = `${association.alias}.ref`;
|
this._mongooseOptions.populate[association.alias].path = `${association.alias}.ref`;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (!this._mongooseOptions.populate) {
|
||||||
|
this._mongooseOptions.populate = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Images are not displayed in populated data.
|
||||||
|
// We automatically populate morph relations.
|
||||||
|
if (association.nature === 'oneToManyMorph' || association.nature === 'manyToManyMorph') {
|
||||||
|
this._mongooseOptions.populate[association.alias] = {
|
||||||
|
path: association.alias,
|
||||||
|
match: {
|
||||||
|
[`${association.via}.${association.filter}`]: association.alias,
|
||||||
|
[`${association.via}.kind`]: definition.globalId
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
sort: '-createdAt'
|
||||||
|
},
|
||||||
|
select: undefined,
|
||||||
|
model: undefined,
|
||||||
|
_docs: {}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user