Skip to content

Commit

Permalink
Deletion errors should break transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
theninj4 committed Jul 1, 2016
1 parent 0722f1e commit 95ae799
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/sqlHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ SqlStore._sequelizeInstances = Object.create(null);
SqlStore.prototype.ready = false;

SqlStore._checkMinServerVersion = function() {
var serverVersion = require('jsonapi-server')._version;
var serverVersion = require("jsonapi-server")._version;
if (!serverVersion) return;
if (semver.lt(serverVersion, MIN_SERVER_VERSION)) {
throw new Error("This version of jsonapi-store-mongodb requires jsonapi-server>=" + MIN_SERVER_VERSION + ".");
Expand Down Expand Up @@ -55,8 +55,8 @@ SqlStore.prototype.initialise = function(resourceConfig) {
// Index the hash map by a hash of the entire config object. If the same config is passed again,
// reuse the existing Sequelize connection resource instead of opening a new one.

var md5sum = crypto.createHash('md5');
var instanceId = md5sum.update(JSON.stringify(sequelizeArgs)).digest('hex');
var md5sum = crypto.createHash("md5");
var instanceId = md5sum.update(JSON.stringify(sequelizeArgs)).digest("hex");
var instances = SqlStore._sequelizeInstances;

if (!instances[instanceId]) {
Expand Down Expand Up @@ -344,8 +344,8 @@ SqlStore.prototype._clearAndSetMany = function(relationModel, prop, theResource,
if (deleteError) return taskCallback(deleteError);

async.map(prop, function(item, acallback) {
relationModel.create(item, t).asCallback(function(err4, newRelationModel) {
if (err4) return acallback(err4);
relationModel.create(item, t).asCallback(function(err, newRelationModel) {
if (err) return acallback(err);

theResource["add" + ucKeyName](newRelationModel, t).asCallback(acallback);
});
Expand All @@ -359,8 +359,8 @@ SqlStore.prototype._clearAndSetOne = function(relationModel, prop, theResource,
if (!prop) {
theResource["set" + ucKeyName](null, t).asCallback(taskCallback);
} else {
relationModel.create(prop, t).asCallback(function(err3, newRelationModel) {
if (err3) return taskCallback(err3);
relationModel.create(prop, t).asCallback(function(err, newRelationModel) {
if (err) return taskCallback(err);

theResource["set" + ucKeyName](newRelationModel, t).asCallback(taskCallback);
});
Expand Down

0 comments on commit 95ae799

Please sign in to comment.