Added behavior journal, adjusted layout, and added some colors
This commit is contained in:
1 parent
b1b89ad334
commit
3237cd7601
31 files changed
+2135
-275
No files matched your search
@@ -23,6 +23,21 @@ export class DatabaseClient {
|
||||
return this.pool.query<T>(text, params);
|
||||
}
|
||||
|
||||
async transaction<T>(operation: (client: pg.PoolClient) => Promise<T>): Promise<T> {
|
||||
const client = await this.pool.connect();
|
||||
try {
|
||||
await client.query('BEGIN');
|
||||
const result = await operation(client);
|
||||
await client.query('COMMIT');
|
||||
return result;
|
||||
} catch (error) {
|
||||
await client.query('ROLLBACK');
|
||||
throw error;
|
||||
} finally {
|
||||
client.release();
|
||||
}
|
||||
}
|
||||
|
||||
async close() {
|
||||
await this.pool.end();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user