Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"extends": "eslint:recommended",
"globals": {
},
"env": {
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- 2016-07-04 - v1.2.4
- 2016-07-04 - Use stricter MySQL transaction isolation READ_COMMITTED
- 2016-07-01 - v1.2.3
- 2016-07-01 - Deletion errors fail transactions
- 2016-06-29 - v1.2.2
Expand Down
40 changes: 21 additions & 19 deletions lib/sqlHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ SqlStore._getSearchBlock = function(filter) {
SqlStore.prototype._dealWithTransaction = function(done, callback) {
var self = this;
var transactionOptions = {
isolationLevel: Sequelize.Transaction.ISOLATION_LEVELS.READ_UNCOMMITTED,
isolationLevel: Sequelize.Transaction.ISOLATION_LEVELS.READ_COMMITTED,
autocommit: false
};
self.sequelize.transaction(transactionOptions).asCallback(function(err1, transaction) {
Expand Down Expand Up @@ -495,29 +495,31 @@ SqlStore.prototype.create = function(request, newResource, finishedCallback) {
/**
Delete a resource, given a resource type and and id.
*/
SqlStore.prototype.delete = function(request, callback) {
SqlStore.prototype.delete = function(request, finishedCallback) {
var self = this;

self.baseModel.findAll({
where: { id: request.params.id },
include: self.relationArray
}).asCallback(function(findErr, results) {
if (findErr) return self._errorHandler(findErr, callback);
self._dealWithTransaction(finishedCallback, function(t, finishTransaction) {
self.baseModel.findAll({
where: { id: request.params.id },
include: self.relationArray
}).asCallback(function(findErr, results) {
if (findErr) return finishTransaction(findErr);

var theResource = results[0];
var theResource = results[0];

// If the resource doesn't exist, error
if (!theResource) {
return callback({
status: "404",
code: "ENOTFOUND",
title: "Requested resource does not exist",
detail: "There is no " + request.params.type + " with id " + request.params.id
});
}
// If the resource doesn't exist, error
if (!theResource) {
return finishTransaction({
status: "404",
code: "ENOTFOUND",
title: "Requested resource does not exist",
detail: "There is no " + request.params.type + " with id " + request.params.id
});
}

theResource.destroy().asCallback(function(deleteErr) {
return callback(deleteErr);
theResource.destroy(t).asCallback(function(deleteErr) {
return finishTransaction(deleteErr);
});
});
});
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsonapi-store-relationaldb",
"version": "1.2.3",
"version": "1.2.4",
"description": "Relational data store for jsonapi-server.",
"keywords": [
"json:api",
Expand Down