Skip to content

Commit

Permalink
use transactions in update, related to feathersjs-ecosystem#188
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangts authored Oct 20, 2018
1 parent 6f5c547 commit f62f440
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}'`);
}
Expand All @@ -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);
Expand Down

0 comments on commit f62f440

Please sign in to comment.