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
  2c0b4cc1_a80b_fa91_526b_b66890112d1a["transaction()"]
  04f6aa0c_c023_3d78_4cb1_98ce96749176["LibSQLTransaction"]
  2c0b4cc1_a80b_fa91_526b_b66890112d1a -->|defined in| 04f6aa0c_c023_3d78_4cb1_98ce96749176
  dfcf521d_dee0_e241_fb38_def3a1295652["transaction()"]
  dfcf521d_dee0_e241_fb38_def3a1295652 -->|calls| 2c0b4cc1_a80b_fa91_526b_b66890112d1a
  5fca71bb_d9cb_5189_8a34_fca357bfc756["run()"]
  2c0b4cc1_a80b_fa91_526b_b66890112d1a -->|calls| 5fca71bb_d9cb_5189_8a34_fca357bfc756
  dfcf521d_dee0_e241_fb38_def3a1295652["transaction()"]
  2c0b4cc1_a80b_fa91_526b_b66890112d1a -->|calls| dfcf521d_dee0_e241_fb38_def3a1295652
  style 2c0b4cc1_a80b_fa91_526b_b66890112d1a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-orm/src/libsql/session.ts lines 150–162

	override async transaction<T>(transaction: (tx: LibSQLTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T> {
		const savepointName = `sp${this.nestedIndex}`;
		const tx = new LibSQLTransaction('async', this.dialect, this.session, this.schema, this.nestedIndex + 1);
		await this.session.run(sql.raw(`savepoint ${savepointName}`));
		try {
			const result = await transaction(tx);
			await this.session.run(sql.raw(`release savepoint ${savepointName}`));
			return result;
		} catch (err) {
			await this.session.run(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/libsql/session.ts.
Where is transaction() defined?
transaction() is defined in drizzle-orm/src/libsql/session.ts at line 150.
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