From 7d66910749e463509636a6cff47c13a5abc666a7 Mon Sep 17 00:00:00 2001 From: Sean Lynch Date: Fri, 23 Oct 2015 00:31:24 -0400 Subject: [PATCH] Stable Version 0.11.4 --- dist/js-data-sql.js | 19 ++++++++++++------- package.json | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/dist/js-data-sql.js b/dist/js-data-sql.js index c85eed5..6e69428 100644 --- a/dist/js-data-sql.js +++ b/dist/js-data-sql.js @@ -67,9 +67,10 @@ module.exports = return resourceConfig.table || underscore(resourceConfig.name); } - function filterQuery(resourceConfig, params) { + function filterQuery(resourceConfig, params, options) { var table = getTable(resourceConfig); - var query = this.query.select(table + '.*').from(table); + var query = options && options.transaction || this.query; + query = query.select(table + '.*').from(table); params = params || {}; params.where = params.where || {}; params.orderBy = params.orderBy || params.sort; @@ -378,7 +379,8 @@ module.exports = var instance = undefined; options = options || {}; options['with'] = options['with'] || []; - return this.query.select('*').from(getTable(resourceConfig)).where(resourceConfig.idAttribute, toString(id)).then(function (rows) { + var query = options && options.transaction || this.query; + return query.select('*').from(getTable(resourceConfig)).where(resourceConfig.idAttribute, toString(id)).then(function (rows) { if (!rows.length) { return DSUtils.Promise.reject(new Error('Not Found!')); } else { @@ -410,7 +412,8 @@ module.exports = var _this4 = this; attrs = DSUtils.removeCircular(DSUtils.omit(attrs, resourceConfig.relationFields || [])); - return this.query(getTable(resourceConfig)).insert(attrs, resourceConfig.idAttribute).then(function (ids) { + var query = options && options.transaction || this.query; + return query(getTable(resourceConfig)).insert(attrs, resourceConfig.idAttribute).then(function (ids) { if (attrs[resourceConfig.idAttribute]) { return _this4.find(resourceConfig, attrs[resourceConfig.idAttribute], options); } else if (ids.length) { @@ -426,7 +429,8 @@ module.exports = var _this5 = this; attrs = DSUtils.removeCircular(DSUtils.omit(attrs, resourceConfig.relationFields || [])); - return this.query(getTable(resourceConfig)).where(resourceConfig.idAttribute, toString(id)).update(attrs).then(function () { + var query = options && options.transaction || this.query; + return query(getTable(resourceConfig)).where(resourceConfig.idAttribute, toString(id)).update(attrs).then(function () { return _this5.find(resourceConfig, id, options); }); } @@ -452,8 +456,9 @@ module.exports = } }, { key: 'destroy', - value: function destroy(resourceConfig, id) { - return this.query(getTable(resourceConfig)).where(resourceConfig.idAttribute, toString(id)).del().then(function () { + value: function destroy(resourceConfig, id, options) { + var query = options && options.transaction || this.query; + return query(getTable(resourceConfig)).where(resourceConfig.idAttribute, toString(id)).del().then(function () { return undefined; }); } diff --git a/package.json b/package.json index 499f7f9..548244a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "js-data-sql", "description": "Postgres/MySQL/MariaDB/SQLite3 adapter for js-data.", - "version": "0.11.3", + "version": "0.11.4", "homepage": "http://www.js-data.io/docs/dssqladapter", "repository": { "type": "git",