further simplification - now using better-sqlite3 native transaction API

pull/255/head
zadam 2020-06-21 13:33:56 +07:00
parent f0acfaf147
commit c34a9b96e4
1 changed files with 3 additions and 21 deletions

@ -211,29 +211,11 @@ function wrap(query, func) {
}
function transactional(func) {
if (dbConnection.inTransaction) {
return func();
}
try {
beginTransaction();
const ret = func();
commit();
const ret = dbConnection.transaction(func).deferred();
// note that sync rows sent from this action will be sent again by scheduled periodic ping
require('./ws.js').sendPingToAllClients();
require('./ws.js').sendPingToAllClients();
return ret;
}
catch (e) {
if (dbConnection.inTransaction) {
rollback();
}
throw e;
}
return ret;
}
module.exports = {