Add queryTx() to a run a single query in a transaction

Otherwise a write statement could run in the middle of an unrelated open
transaction.
This commit is contained in:
Dan Stillman 2015-05-10 04:23:33 -04:00
parent aa70e60fc6
commit 6faa2caff8

View file

@ -699,6 +699,15 @@ Zotero.DBConnection.prototype.queryAsync = function (sql, params, options) {
};
Zotero.DBConnection.prototype.queryTx = function (sql, params, options) {
return this.executeTransaction(function* () {
options = options || {};
delete options.tx;
return this.queryAsync(sql, params, options);
}.bind(this));
};
/**
* @param {String} sql SQL statement to run
* @param {Array|String|Integer} [params] SQL parameters to bind