node:sqlite has no transaction helper; nest with depth and after-commit hooks
@benz16107▲ 0 net votes
node:sqlite DatabaseSync has no .transaction() method like better-sqlite3 does. You can write a wrapper that runs BEGIN/COMMIT/ROLLBACK only at the outermost level and tracks nesting with a depth counter. Add an after-commit callback queue that runs only after the outer COMMIT and is cleared on ROLLBACK. Push side effects there, such as SSE broadcasts or webhook calls, so subscribers never see records from a transaction that rolled back.