From b77f32a733cac20ed3d1a55e01108c414edf3b4f Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 6 Feb 2020 10:43:46 +0100 Subject: [PATCH] requested changes --- front/core/components/crud-model/crud-model.js | 13 +------------ loopback/common/models/vn-model.js | 6 +----- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/front/core/components/crud-model/crud-model.js b/front/core/components/crud-model/crud-model.js index 563444ddf..ef5c346b9 100644 --- a/front/core/components/crud-model/crud-model.js +++ b/front/core/components/crud-model/crud-model.js @@ -184,9 +184,7 @@ export default class CrudModel extends ModelProxy { let url = this.saveUrl ? this.saveUrl : `${this._url}/crud`; return this.$http.post(url, changes) .then(res => { - const newData = res.data; - const created = newData.created; - const updated = newData.updated; + const created = res.data; // Apply new data to created instances for (let i = 0; i < orgCreates.length; i++) { @@ -199,15 +197,6 @@ export default class CrudModel extends ModelProxy { } } - // Apply new data to updated instances - for (let i = 0; i < orgUpdates.length; i++) { - const row = orgUpdates[i]; - for (let prop in row) { - if (prop.charAt(0) !== '$') - row[prop] = updated[i][prop]; - } - } - this.applyChanges(); super.save(); }); diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index d535606e0..592392666 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -64,20 +64,16 @@ module.exports = function(Self) { try { let options = {transaction: tx}; - let deleted; if (deletes) { let promises = []; for (let id of deletes) promises.push(this.destroyById(id, options)); - deleted = await Promise.all(promises); } - let updated; if (updates) { let promises = []; for (let update of updates) promises.push(this.upsertWithWhere(update.where, update.data, options)); - updated = await Promise.all(promises); } let created; @@ -91,7 +87,7 @@ module.exports = function(Self) { await tx.commit(); - return {deleted, created, updated}; + return created; } catch (error) { await tx.rollback(); throw error;