refactor(server): remove DatabaseService.transaction — every transaction runs through UnitOfWork

This commit is contained in:
jubnl
2026-09-22 06:39:38 +02:00
parent a0f50c8316
commit 39a6d991ce
6 changed files with 7 additions and 16 deletions
+3 -2
View File
@@ -914,8 +914,9 @@ cycle seams are folded, nothing on the websocket path imports one, and the
crons all inject now (`*.job.ts` providers on `scheduling/CronRegistrarService`).
1. **Move the SQL** into `<domain>.service.ts` as methods over an injected
`DatabaseService` (`this.db.all<T>/get<T>/run/prepare/transaction`; strict
constructor injection, no `@Optional()`). Preserve every quirk: falsy-coercion
`DatabaseService` (`this.db.all<T>/get<T>/run/prepare`; multi-statement writes go
through `await this.uow.transactional(...)` instead — see the root `CLAUDE.md`;
strict constructor injection, no `@Optional()`). Preserve every quirk: falsy-coercion
defaults (`x || fallback`, never `??`), post-insert/post-update re-selects (no
RETURNING), `COALESCE` semantics. If a controller already wraps the legacy
functions, do not change the service's method surface. The module needs no
@@ -38,11 +38,6 @@ export class DatabaseService {
return this.conn.prepare(sql).run(...params);
}
/** Run `fn` inside a synchronous better-sqlite3 transaction. */
transaction<T>(fn: (conn: Database.Database) => T): T {
return this.conn.transaction(() => fn(this.conn))();
}
// Trip-access helpers delegate to the db/database exports (not this.conn):
// tests vi.mock that module and stub the helpers themselves, so the stubs
// must keep flowing through here.