Skip to content

Build your personal knowledge base with Trilium Notes

further simplification - now using better-sqlite3 native transaction API

zadamc34a9b96e4e1
diff --git a/src/services/sql.js b/src/services/sql.js
index cdd1a29553..1b997ab7c3 100644
--- a/src/services/sql.js
+++ b/src/services/sql.js
@@ -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 = {