Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1a9a663

Browse files
committedOct 23, 2015
Merge pull request #33 from js-data/develop
Stable Version 0.11.4
2 parents 41c8831 + 7d66910 commit 1a9a663

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed
 

‎dist/js-data-sql.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ module.exports =
6767
return resourceConfig.table || underscore(resourceConfig.name);
6868
}
6969

70-
function filterQuery(resourceConfig, params) {
70+
function filterQuery(resourceConfig, params, options) {
7171
var table = getTable(resourceConfig);
72-
var query = this.query.select(table + '.*').from(table);
72+
var query = options && options.transaction || this.query;
73+
query = query.select(table + '.*').from(table);
7374
params = params || {};
7475
params.where = params.where || {};
7576
params.orderBy = params.orderBy || params.sort;
@@ -378,7 +379,8 @@ module.exports =
378379
var instance = undefined;
379380
options = options || {};
380381
options['with'] = options['with'] || [];
381-
return this.query.select('*').from(getTable(resourceConfig)).where(resourceConfig.idAttribute, toString(id)).then(function (rows) {
382+
var query = options && options.transaction || this.query;
383+
return query.select('*').from(getTable(resourceConfig)).where(resourceConfig.idAttribute, toString(id)).then(function (rows) {
382384
if (!rows.length) {
383385
return DSUtils.Promise.reject(new Error('Not Found!'));
384386
} else {
@@ -410,7 +412,8 @@ module.exports =
410412
var _this4 = this;
411413

412414
attrs = DSUtils.removeCircular(DSUtils.omit(attrs, resourceConfig.relationFields || []));
413-
return this.query(getTable(resourceConfig)).insert(attrs, resourceConfig.idAttribute).then(function (ids) {
415+
var query = options && options.transaction || this.query;
416+
return query(getTable(resourceConfig)).insert(attrs, resourceConfig.idAttribute).then(function (ids) {
414417
if (attrs[resourceConfig.idAttribute]) {
415418
return _this4.find(resourceConfig, attrs[resourceConfig.idAttribute], options);
416419
} else if (ids.length) {
@@ -426,7 +429,8 @@ module.exports =
426429
var _this5 = this;
427430

428431
attrs = DSUtils.removeCircular(DSUtils.omit(attrs, resourceConfig.relationFields || []));
429-
return this.query(getTable(resourceConfig)).where(resourceConfig.idAttribute, toString(id)).update(attrs).then(function () {
432+
var query = options && options.transaction || this.query;
433+
return query(getTable(resourceConfig)).where(resourceConfig.idAttribute, toString(id)).update(attrs).then(function () {
430434
return _this5.find(resourceConfig, id, options);
431435
});
432436
}
@@ -452,8 +456,9 @@ module.exports =
452456
}
453457
}, {
454458
key: 'destroy',
455-
value: function destroy(resourceConfig, id) {
456-
return this.query(getTable(resourceConfig)).where(resourceConfig.idAttribute, toString(id)).del().then(function () {
459+
value: function destroy(resourceConfig, id, options) {
460+
var query = options && options.transaction || this.query;
461+
return query(getTable(resourceConfig)).where(resourceConfig.idAttribute, toString(id)).del().then(function () {
457462
return undefined;
458463
});
459464
}

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "js-data-sql",
33
"description": "Postgres/MySQL/MariaDB/SQLite3 adapter for js-data.",
4-
"version": "0.11.3",
4+
"version": "0.11.4",
55
"homepage": "http://www.js-data.io/docs/dssqladapter",
66
"repository": {
77
"type": "git",

0 commit comments

Comments
 (0)
Please sign in to comment.