This commit is contained in:
Jim Laurie 2018-04-30 17:14:13 +02:00
parent f91be5ce63
commit 596adb5f61
8 changed files with 16 additions and 30 deletions

View File

@ -140,30 +140,16 @@ module.exports = {
types.current = 'modelD';
// We have to find if they are a model linked to this key
_.forIn(_.omit(models, currentModelName || ''), model => {
Object.keys(model.attributes)
.filter(key => key === association.via)
.forEach(attr => {
const attribute = model.attributes[attr];
const model = models[association.model]
const attribute = model.attributes[association.via];
if (attribute.hasOwnProperty('via') && attribute.via === key && attribute.hasOwnProperty('collection') && attribute.collection !== '*') {
types.other = 'collection';
// Break loop
return false;
} else if (attribute.hasOwnProperty('model') && attribute.model !== '*') {
types.other = 'model';
// Break loop
return false;
} else if (attribute.hasOwnProperty('collection') || attribute.hasOwnProperty('model')) {
types.other = 'morphTo';
// Break loop
return false;
}
});
});
} else if (association.hasOwnProperty('model')) {
types.current = 'model';