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

Relationship Graph

Source Code

drizzle-orm/src/aws-data-api/pg/session.ts lines 238–256

	override async transaction<T>(
		transaction: (tx: AwsDataApiTransaction<TFullSchema, TSchema>) => Promise<T>,
		config?: PgTransactionConfig | undefined,
	): Promise<T> {
		const { transactionId } = await this.client.send(new BeginTransactionCommand(this.rawQuery));
		const session = new AwsDataApiSession(this.client, this.dialect, this.schema, this.options, transactionId);
		const tx = new AwsDataApiTransaction<TFullSchema, TSchema>(this.dialect, session, this.schema);
		if (config) {
			await tx.setTransaction(config);
		}
		try {
			const result = await transaction(tx);
			await this.client.send(new CommitTransactionCommand({ ...this.rawQuery, transactionId }));
			return result;
		} catch (e) {
			await this.client.send(new RollbackTransactionCommand({ ...this.rawQuery, transactionId }));
			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 238.
What does transaction() call?
transaction() calls 1 function(s): 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