NodePgTransaction Class — drizzle-orm Architecture
Architecture documentation for the NodePgTransaction class in session.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 5c838b89_938f_05a3_718d_06ed6215bf56["NodePgTransaction"] 0507ccca_3cb1_384d_6315_fc19900c69b1["session.ts"] 5c838b89_938f_05a3_718d_06ed6215bf56 -->|defined in| 0507ccca_3cb1_384d_6315_fc19900c69b1 e97f13b3_0abe_008f_2902_c0f8644c9e20["transaction()"] 5c838b89_938f_05a3_718d_06ed6215bf56 -->|method| e97f13b3_0abe_008f_2902_c0f8644c9e20
Relationship Graph
Source Code
drizzle-orm/src/node-postgres/session.ts lines 278–302
export class NodePgTransaction<
TFullSchema extends Record<string, unknown>,
TSchema extends TablesRelationalConfig,
> extends PgTransaction<NodePgQueryResultHKT, TFullSchema, TSchema> {
static override readonly [entityKind]: string = 'NodePgTransaction';
override async transaction<T>(transaction: (tx: NodePgTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T> {
const savepointName = `sp${this.nestedIndex + 1}`;
const tx = new NodePgTransaction<TFullSchema, TSchema>(
this.dialect,
this.session,
this.schema,
this.nestedIndex + 1,
);
await tx.execute(sql.raw(`savepoint ${savepointName}`));
try {
const result = await transaction(tx);
await tx.execute(sql.raw(`release savepoint ${savepointName}`));
return result;
} catch (err) {
await tx.execute(sql.raw(`rollback to savepoint ${savepointName}`));
throw err;
}
}
}
Domain
Defined In
Source
Frequently Asked Questions
What is the NodePgTransaction class?
NodePgTransaction is a class in the drizzle-orm codebase, defined in drizzle-orm/src/node-postgres/session.ts.
Where is NodePgTransaction defined?
NodePgTransaction is defined in drizzle-orm/src/node-postgres/session.ts at line 278.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free