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
  64c77bc2_2026_921b_fd5a_d62bfc217ad6["transaction()"]
  6e5968f3_3f01_5fbb_b14b_e64c88c7916a["SQLJsSession"]
  64c77bc2_2026_921b_fd5a_d62bfc217ad6 -->|defined in| 6e5968f3_3f01_5fbb_b14b_e64c88c7916a
  6ebbfd4b_527b_e473_a19c_04511fe038fb["transaction()"]
  6ebbfd4b_527b_e473_a19c_04511fe038fb -->|calls| 64c77bc2_2026_921b_fd5a_d62bfc217ad6
  a8b9aa76_08ef_960b_7cba_6f7e5c867df3["run()"]
  64c77bc2_2026_921b_fd5a_d62bfc217ad6 -->|calls| a8b9aa76_08ef_960b_7cba_6f7e5c867df3
  6ebbfd4b_527b_e473_a19c_04511fe038fb["transaction()"]
  64c77bc2_2026_921b_fd5a_d62bfc217ad6 -->|calls| 6ebbfd4b_527b_e473_a19c_04511fe038fb
  style 64c77bc2_2026_921b_fd5a_d62bfc217ad6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-orm/src/sql-js/session.ts lines 51–65

	override transaction<T>(
		transaction: (tx: SQLJsTransaction<TFullSchema, TSchema>) => T,
		config: SQLiteTransactionConfig = {},
	): T {
		const tx = new SQLJsTransaction('sync', this.dialect, this, this.schema);
		this.run(sql.raw(`begin${config.behavior ? ` ${config.behavior}` : ''}`));
		try {
			const result = transaction(tx);
			this.run(sql`commit`);
			return result;
		} catch (err) {
			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/sql-js/session.ts.
Where is transaction() defined?
transaction() is defined in drizzle-orm/src/sql-js/session.ts at line 51.
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