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
  8a26552d_acc1_0ef9_c339_f7c6004922f3["transaction()"]
  d99a9a29_a84e_fe26_23e2_747611bfea48["SingleStoreDriverTransaction"]
  8a26552d_acc1_0ef9_c339_f7c6004922f3 -->|defined in| d99a9a29_a84e_fe26_23e2_747611bfea48
  97e806e9_97b7_074b_ac57_aab19d4bbc66["transaction()"]
  97e806e9_97b7_074b_ac57_aab19d4bbc66 -->|calls| 8a26552d_acc1_0ef9_c339_f7c6004922f3
  0f9540de_5358_69fd_b854_4371666724a9["execute()"]
  8a26552d_acc1_0ef9_c339_f7c6004922f3 -->|calls| 0f9540de_5358_69fd_b854_4371666724a9
  97e806e9_97b7_074b_ac57_aab19d4bbc66["transaction()"]
  8a26552d_acc1_0ef9_c339_f7c6004922f3 -->|calls| 97e806e9_97b7_074b_ac57_aab19d4bbc66
  style 8a26552d_acc1_0ef9_c339_f7c6004922f3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-orm/src/singlestore/session.ts lines 331–350

	override async transaction<T>(
		transaction: (tx: SingleStoreDriverTransaction<TFullSchema, TSchema>) => Promise<T>,
	): Promise<T> {
		const savepointName = `sp${this.nestedIndex + 1}`;
		const tx = new SingleStoreDriverTransaction<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

Subdomains

Called By

Frequently Asked Questions

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