mirror of
https://github.com/zadam/trilium.git
synced 2025-06-05 01:18:44 +02:00
further simplification - now using better-sqlite3 native transaction API
This commit is contained in:
parent
f0acfaf147
commit
c34a9b96e4
@ -211,29 +211,11 @@ function wrap(query, func) {
|
||||
}
|
||||
|
||||
function transactional(func) {
|
||||
if (dbConnection.inTransaction) {
|
||||
return func();
|
||||
}
|
||||
const ret = dbConnection.transaction(func).deferred();
|
||||
|
||||
try {
|
||||
beginTransaction();
|
||||
require('./ws.js').sendPingToAllClients();
|
||||
|
||||
const ret = func();
|
||||
|
||||
commit();
|
||||
|
||||
// note that sync rows sent from this action will be sent again by scheduled periodic ping
|
||||
require('./ws.js').sendPingToAllClients();
|
||||
|
||||
return ret;
|
||||
}
|
||||
catch (e) {
|
||||
if (dbConnection.inTransaction) {
|
||||
rollback();
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user