Fix media relation update

This commit is contained in:
Jim Laurie 2018-05-17 14:56:53 +02:00
parent 6b2e1f2bde
commit 5175ee6336

View File

@ -21,7 +21,8 @@ module.exports = {
.findOne({
[this.primaryKey]: params[this.primaryKey] || params.id
})
.populate(this.associations.map(x => x.alias).join(' '));
.populate(this.associations.map(x => x.alias).join(' '))
.lean();
// Only update fields which are on this document.
const values = params.parseRelationships === false ? params.values : Object.keys(JSON.parse(JSON.stringify(params.values))).reduce((acc, current) => {
@ -270,13 +271,17 @@ module.exports = {
However the upload doesn't need this method. It only uses the `removeRelationMorph`.
*/
const entry = (
let entry = (
await this
.findOne({
[this.primaryKey]: getValuePrimaryKey(params, this.primaryKey)
})
.toJSON()
);
if (entry) {
entry = entry.toJSON();
}
const value = [];
// Retrieve association.