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
  edc293b9_1f8b_73c9_efa3_55f353a3b344["transaction()"]
  8547eb9d_d783_00ed_fafd_5d4e77e8be54["SQLiteRemoteSession"]
  edc293b9_1f8b_73c9_efa3_55f353a3b344 -->|defined in| 8547eb9d_d783_00ed_fafd_5d4e77e8be54
  6eb2105d_a07f_dc00_c56f_931a711ee608["transaction()"]
  6eb2105d_a07f_dc00_c56f_931a711ee608 -->|calls| edc293b9_1f8b_73c9_efa3_55f353a3b344
  24c3dc35_447a_e607_7a19_f28b54bde3d6["run()"]
  edc293b9_1f8b_73c9_efa3_55f353a3b344 -->|calls| 24c3dc35_447a_e607_7a19_f28b54bde3d6
  6eb2105d_a07f_dc00_c56f_931a711ee608["transaction()"]
  edc293b9_1f8b_73c9_efa3_55f353a3b344 -->|calls| 6eb2105d_a07f_dc00_c56f_931a711ee608
  style edc293b9_1f8b_73c9_efa3_55f353a3b344 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-orm/src/sqlite-proxy/session.ts lines 91–105

	override async transaction<T>(
		transaction: (tx: SQLiteProxyTransaction<TFullSchema, TSchema>) => Promise<T>,
		config?: SQLiteTransactionConfig,
	): Promise<T> {
		const tx = new SQLiteProxyTransaction('async', this.dialect, this, this.schema);
		await this.run(sql.raw(`begin${config?.behavior ? ' ' + config.behavior : ''}`));
		try {
			const result = await transaction(tx);
			await this.run(sql`commit`);
			return result;
		} catch (err) {
			await this.run(sql`rollback`);
			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/sqlite-proxy/session.ts.
Where is transaction() defined?
transaction() is defined in drizzle-orm/src/sqlite-proxy/session.ts at line 91.
What does transaction() call?
transaction() calls 2 function(s): run, 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