transaction() — drizzle-orm Function Reference
Architecture documentation for the transaction() function in session.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 0df49818_fd3d_7eaf_026f_4bb7ca00ab17["transaction()"] bef17a4b_1799_4883_f38d_851173aa1ff4["NeonSession"] 0df49818_fd3d_7eaf_026f_4bb7ca00ab17 -->|defined in| bef17a4b_1799_4883_f38d_851173aa1ff4 bd152654_7670_2106_bc9f_e0113b3e1db9["transaction()"] bd152654_7670_2106_bc9f_e0113b3e1db9 -->|calls| 0df49818_fd3d_7eaf_026f_4bb7ca00ab17 afed55a9_87b6_c85c_1288_688d4915117f["execute()"] 0df49818_fd3d_7eaf_026f_4bb7ca00ab17 -->|calls| afed55a9_87b6_c85c_1288_688d4915117f bd152654_7670_2106_bc9f_e0113b3e1db9["transaction()"] 0df49818_fd3d_7eaf_026f_4bb7ca00ab17 -->|calls| bd152654_7670_2106_bc9f_e0113b3e1db9 style 0df49818_fd3d_7eaf_026f_4bb7ca00ab17 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-orm/src/neon-serverless/session.ts lines 260–281
override async transaction<T>(
transaction: (tx: NeonTransaction<TFullSchema, TSchema>) => Promise<T>,
config: PgTransactionConfig = {},
): Promise<T> {
const session = this.client instanceof Pool // eslint-disable-line no-instanceof/no-instanceof
? new NeonSession(await this.client.connect(), this.dialect, this.schema, this.options)
: this;
const tx = new NeonTransaction<TFullSchema, TSchema>(this.dialect, session, this.schema);
await tx.execute(sql`begin ${tx.getTransactionConfigSQL(config)}`);
try {
const result = await transaction(tx);
await tx.execute(sql`commit`);
return result;
} catch (error) {
await tx.execute(sql`rollback`);
throw error;
} finally {
if (this.client instanceof Pool) { // eslint-disable-line no-instanceof/no-instanceof
(session.client as PoolClient).release();
}
}
}
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does transaction() do?
transaction() is a function in the drizzle-orm codebase, defined in drizzle-orm/src/neon-serverless/session.ts.
Where is transaction() defined?
transaction() is defined in drizzle-orm/src/neon-serverless/session.ts at line 260.
What does transaction() call?
transaction() calls 2 function(s): execute, transaction.
What calls transaction()?
transaction() is called by 1 function(s): transaction.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free