Home / Function/ transaction() — drizzle-orm Function Reference

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
  c336da65_f93c_cb64_7b24_385b17f7a894["transaction()"]
  81a4e159_1fd1_64d3_dcd4_a1fbabbc531f["VercelPgSession"]
  c336da65_f93c_cb64_7b24_385b17f7a894 -->|defined in| 81a4e159_1fd1_64d3_dcd4_a1fbabbc531f
  d0b3aff2_b6a7_17f5_d12c_5e00e54eb727["transaction()"]
  d0b3aff2_b6a7_17f5_d12c_5e00e54eb727 -->|calls| c336da65_f93c_cb64_7b24_385b17f7a894
  3a6e8138_0409_5715_8044_528b249e7919["execute()"]
  c336da65_f93c_cb64_7b24_385b17f7a894 -->|calls| 3a6e8138_0409_5715_8044_528b249e7919
  d0b3aff2_b6a7_17f5_d12c_5e00e54eb727["transaction()"]
  c336da65_f93c_cb64_7b24_385b17f7a894 -->|calls| d0b3aff2_b6a7_17f5_d12c_5e00e54eb727
  style c336da65_f93c_cb64_7b24_385b17f7a894 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-orm/src/vercel-postgres/session.ts lines 258–279

	override async transaction<T>(
		transaction: (tx: VercelPgTransaction<TFullSchema, TSchema>) => Promise<T>,
		config?: PgTransactionConfig | undefined,
	): Promise<T> {
		const session = this.client instanceof VercelPool // eslint-disable-line no-instanceof/no-instanceof
			? new VercelPgSession(await this.client.connect(), this.dialect, this.schema, this.options)
			: this;
		const tx = new VercelPgTransaction<TFullSchema, TSchema>(this.dialect, session, this.schema);
		await tx.execute(sql`begin${config ? sql` ${tx.getTransactionConfigSQL(config)}` : undefined}`);
		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 VercelPool) { // eslint-disable-line no-instanceof/no-instanceof
				(session.client as VercelPoolClient).release();
			}
		}
	}

Domain

Subdomains

Called By

Frequently Asked Questions

What does transaction() do?
transaction() is a function in the drizzle-orm codebase, defined in drizzle-orm/src/vercel-postgres/session.ts.
Where is transaction() defined?
transaction() is defined in drizzle-orm/src/vercel-postgres/session.ts at line 258.
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