(closure: () => T)
| 58 | } |
| 59 | |
| 60 | transactionSync<T>(closure: () => T): T { |
| 61 | this.db.exec("BEGIN"); |
| 62 | try { |
| 63 | const result = closure(); |
| 64 | this.db.exec("COMMIT"); |
| 65 | return result; |
| 66 | } catch (error) { |
| 67 | this.db.exec("ROLLBACK"); |
| 68 | throw error; |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | close(): void { |
| 73 | // StatementSync instances are released when the database closes. |