MCPcopy Create free account
hub / github.com/3dugc/3D-Model-Optimizer / withPostgresTransaction

Function withPostgresTransaction

src/database/postgres.ts:38–52  ·  view source on GitHub ↗
(callback: (client: PoolClient) => Promise<T>)

Source from the content-addressed store, hash-verified

36}
37
38export async function withPostgresTransaction<T>(callback: (client: PoolClient) => Promise<T>): Promise<T> {
39 const client = await getPostgresPool().connect();
40 try {
41 await ensurePostgresSchema();
42 await client.query('BEGIN');
43 const result = await callback(client);
44 await client.query('COMMIT');
45 return result;
46 } catch (error) {
47 await client.query('ROLLBACK');
48 throw error;
49 } finally {
50 client.release();
51 }
52}
53
54async function runMigrations(client: SqlQueryable): Promise<void> {
55 await client.query(`

Callers 13

upsertWechatUserMethod · 0.90
upsertAuthServiceUserMethod · 0.90
markRechargePaidMethod · 0.90
holdJobChargeMethod · 0.90
finishJobChargeMethod · 0.90
updateMethod · 0.90
transitionMethod · 0.90
claimMethod · 0.90
claimNextMethod · 0.90
renewLeaseMethod · 0.90
updateMethod · 0.90

Calls 4

getPostgresPoolFunction · 0.85
ensurePostgresSchemaFunction · 0.85
queryMethod · 0.80
releaseMethod · 0.65

Tested by

no test coverage detected