mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +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) {
|
function transactional(func) {
|
||||||
if (dbConnection.inTransaction) {
|
const ret = dbConnection.transaction(func).deferred();
|
||||||
return func();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
require('./ws.js').sendPingToAllClients();
|
||||||
beginTransaction();
|
|
||||||
|
|
||||||
const ret = func();
|
return ret;
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user