mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 23:24:03 +00:00
Merge branch 'master' into strapi-upload-rackspace
This commit is contained in:
commit
2931ad5315
@ -116,6 +116,11 @@ module.exports = function (strapi) {
|
||||
[`${association.via}.${association.filter}`]: association.alias,
|
||||
[`${association.via}.kind`]: definition.globalId
|
||||
}
|
||||
|
||||
// Select last related to an entity.
|
||||
this._mongooseOptions.populate[association.alias].options = {
|
||||
sort: '-createdAt'
|
||||
}
|
||||
} else {
|
||||
this._mongooseOptions.populate[association.alias].path = `${association.alias}.ref`;
|
||||
}
|
||||
@ -180,6 +185,7 @@ module.exports = function (strapi) {
|
||||
break;
|
||||
case 'manyMorphToMany':
|
||||
case 'manyMorphToOne':
|
||||
|
||||
returned[association.alias] = returned[association.alias].map(obj => obj.ref);
|
||||
break;
|
||||
default:
|
||||
|
||||
@ -235,7 +235,7 @@ module.exports = {
|
||||
})
|
||||
}
|
||||
|
||||
if (association.type === 'model') {
|
||||
if (association.type === 'model' || (association.type === 'collection' && _.isObject(array))) {
|
||||
return _.isEmpty(array) ? [] : transformToArrayID([array]);
|
||||
}
|
||||
|
||||
|
||||
@ -211,21 +211,21 @@ module.exports = {
|
||||
case 'manyToManyMorph':
|
||||
const transformToArrayID = (array) => {
|
||||
if (_.isArray(array)) {
|
||||
return array.map(value => {
|
||||
if (_.isPlainObject(value)) {
|
||||
return value._id || value.id;
|
||||
}
|
||||
return array.map(value => {
|
||||
if (_.isPlainObject(value)) {
|
||||
return value._id || value.id;
|
||||
}
|
||||
|
||||
return value;
|
||||
})
|
||||
}
|
||||
return value;
|
||||
})
|
||||
}
|
||||
|
||||
if (association.type === 'model') {
|
||||
return _.isEmpty(array) ? [] : transformToArrayID([array]);
|
||||
}
|
||||
if (association.type === 'model' || (association.type === 'collection' && _.isObject(array))) {
|
||||
return _.isEmpty(array) ? [] : transformToArrayID([array]);
|
||||
}
|
||||
|
||||
return [];
|
||||
};
|
||||
return [];
|
||||
};
|
||||
|
||||
// Compare array of ID to find deleted files.
|
||||
const currentValue = transformToArrayID(response[current]).map(id => id.toString());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user