correctly access the ref of the given model as param

This commit is contained in:
Kamal Bennani 2018-05-14 20:55:26 +02:00
parent be148bd5c5
commit ba809f6149
No known key found for this signature in database
GPG Key ID: 4513063CDB1A1C25

View File

@ -544,14 +544,9 @@ module.exports = {
if (association.type === 'model') {
params.id = obj[association.alias];
} else {
// Get attribute.
const attr = association.plugin ?
strapi.plugins[association.plugin].models[params.model].attributes[association.via]:
strapi.models[params.model].attributes[association.via];
// Get refering model.
const ref = attr.plugin ?
strapi.plugins[attr.plugin].models[params.model]:
const ref = association.plugin ?
strapi.plugins[association.plugin].models[params.model]:
strapi.models[params.model];
// Apply optional arguments to make more precise nested request.