mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 10:55:37 +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 {
|
||||
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();
|
||||
});
|
||||
@ -554,4 +576,4 @@ module.exports = function (strapi) {
|
||||
}, relations);
|
||||
|
||||
return hook;
|
||||
};
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user