From f62f440648d07573c6e02340a9fba7d69bdde4fd Mon Sep 17 00:00:00 2001 From: Allan Jiang Date: Fri, 19 Oct 2018 17:21:49 -0700 Subject: [PATCH 1/2] use transactions in `update`, related to #188 --- lib/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 10eeed2..77a84cd 100644 --- a/lib/index.js +++ b/lib/index.js @@ -240,8 +240,9 @@ class Service { // Force the {raw: false} option as the instance is needed to properly // update + const updateOptions = Object.assign({ raw: false }, params.sequelize); - return this._get(id, { sequelize: { raw: false }, query: where }).then(instance => { + return this._get(id, { sequelize: updateOptions, query: where }).then(instance => { if (!instance) { throw new errors.NotFound(`No record found for id '${id}'`); } @@ -255,7 +256,7 @@ class Service { } }); - return instance.update(copy, {raw: false}).then(() => this._get(id, {sequelize: options})); + return instance.update(copy, updateOptions).then(() => this._get(id, {sequelize: options})); }) .then(select(params, this.id)) .catch(utils.errorHandler); From fb3e85fc5000c1878384a51a7ccd3568e0de5db4 Mon Sep 17 00:00:00 2001 From: Allan Jiang Date: Fri, 19 Oct 2018 21:12:23 -0700 Subject: [PATCH 2/2] revert to raw get query --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 77a84cd..c751cdf 100644 --- a/lib/index.js +++ b/lib/index.js @@ -242,7 +242,7 @@ class Service { // update const updateOptions = Object.assign({ raw: false }, params.sequelize); - return this._get(id, { sequelize: updateOptions, query: where }).then(instance => { + return this._get(id, { sequelize: { raw: false }, query: where }).then(instance => { if (!instance) { throw new errors.NotFound(`No record found for id '${id}'`); }