(db: Database, operation: () => void)
| 1 | import type Database from 'better-sqlite3' |
| 2 | |
| 3 | export function runInTransaction(db: Database, operation: () => void) { |
| 4 | db.exec('BEGIN') |
| 5 | |
| 6 | try { |
| 7 | operation() |
| 8 | db.exec('COMMIT') |
| 9 | } catch (error) { |
| 10 | db.exec('ROLLBACK') |
| 11 | throw error |
| 12 | } |
| 13 | } |
no test coverage detected