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:
parent
aa70e60fc6
commit
6faa2caff8
1 changed files with 9 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue