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
  a5bffa53_aeda_b1e9_5f53_01f64f88075c["transaction()"]
  4ccfc481_43f4_455c_7944_04def59ee87a["AwsDataApiTransaction"]
  a5bffa53_aeda_b1e9_5f53_01f64f88075c -->|defined in| 4ccfc481_43f4_455c_7944_04def59ee87a
  9a2e43e2_718c_8f28_8c34_554851e1626b["transaction()"]
  9a2e43e2_718c_8f28_8c34_554851e1626b -->|calls| a5bffa53_aeda_b1e9_5f53_01f64f88075c
  9a2e43e2_718c_8f28_8c34_554851e1626b["transaction()"]
  a5bffa53_aeda_b1e9_5f53_01f64f88075c -->|calls| 9a2e43e2_718c_8f28_8c34_554851e1626b
  bdabd7a9_60b0_77c5_09b6_e9dbcc404675["execute()"]
  a5bffa53_aeda_b1e9_5f53_01f64f88075c -->|calls| bdabd7a9_60b0_77c5_09b6_e9dbcc404675
  style a5bffa53_aeda_b1e9_5f53_01f64f88075c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-orm/src/aws-data-api/pg/session.ts lines 265–284

	override async transaction<T>(
		transaction: (tx: AwsDataApiTransaction<TFullSchema, TSchema>) => Promise<T>,
	): Promise<T> {
		const savepointName = `sp${this.nestedIndex + 1}`;
		const tx = new AwsDataApiTransaction<TFullSchema, TSchema>(
			this.dialect,
			this.session,
			this.schema,
			this.nestedIndex + 1,
		);
		await this.session.execute(sql.raw(`savepoint ${savepointName}`));
		try {
			const result = await transaction(tx);
			await this.session.execute(sql.raw(`release savepoint ${savepointName}`));
			return result;
		} catch (e) {
			await this.session.execute(sql.raw(`rollback to savepoint ${savepointName}`));
			throw e;
		}
	}

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/aws-data-api/pg/session.ts.
Where is transaction() defined?
transaction() is defined in drizzle-orm/src/aws-data-api/pg/session.ts at line 265.
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