Fix mongo toObject on null objectes

This commit is contained in:
Alexandre Bodin 2019-08-01 15:59:21 +02:00
parent 09761294e9
commit 515d756626
2 changed files with 4 additions and 2 deletions

View File

@ -400,7 +400,7 @@ module.exports = {
transacting,
});
return result.toJSON ? result.toJSON() : result;
return result && result.toJSON ? result.toJSON() : result;
},
async addRelationMorph(params, { transacting } = {}) {

View File

@ -307,7 +307,9 @@ module.exports = {
[this.primaryKey]: primaryKeyValue,
}).populate(populate);
return updatedEntity.toObject ? updatedEntity.toObject() : updatedEntity;
return updatedEntity && updatedEntity.toObject
? updatedEntity.toObject()
: updatedEntity;
},
addRelationMorph: async function(params) {