Set the entry type only when the value is defined

This commit is contained in:
Kamal Bennani 2018-06-08 20:27:45 +02:00
parent e9fc37d03a
commit 4920c1fa76
No known key found for this signature in database
GPG Key ID: 4513063CDB1A1C25

View File

@ -533,7 +533,10 @@ module.exports = {
const entry = withRelated && withRelated.toJSON ? withRelated.toJSON() : withRelated; const entry = withRelated && withRelated.toJSON ? withRelated.toJSON() : withRelated;
entry[association.alias]._type = _.upperFirst(association.model); // Set the _type only when the value is defined
if (entry[association.alias]) {
entry[association.alias]._type = _.upperFirst(association.model);
}
return entry[association.alias]; return entry[association.alias];
} }