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
  dfcf521d_dee0_e241_fb38_def3a1295652["transaction()"]
  916e21cc_0bbc_927f_ecfb_2147725c35d9["LibSQLSession"]
  dfcf521d_dee0_e241_fb38_def3a1295652 -->|defined in| 916e21cc_0bbc_927f_ecfb_2147725c35d9
  2c0b4cc1_a80b_fa91_526b_b66890112d1a["transaction()"]
  2c0b4cc1_a80b_fa91_526b_b66890112d1a -->|calls| dfcf521d_dee0_e241_fb38_def3a1295652
  2c0b4cc1_a80b_fa91_526b_b66890112d1a["transaction()"]
  dfcf521d_dee0_e241_fb38_def3a1295652 -->|calls| 2c0b4cc1_a80b_fa91_526b_b66890112d1a
  style dfcf521d_dee0_e241_fb38_def3a1295652 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-orm/src/libsql/session.ts lines 107–129

	override async transaction<T>(
		transaction: (db: LibSQLTransaction<TFullSchema, TSchema>) => T | Promise<T>,
		_config?: SQLiteTransactionConfig,
	): Promise<T> {
		// TODO: support transaction behavior
		const libsqlTx = await this.client.transaction();
		const session = new LibSQLSession<TFullSchema, TSchema>(
			this.client,
			this.dialect,
			this.schema,
			this.options,
			libsqlTx,
		);
		const tx = new LibSQLTransaction<TFullSchema, TSchema>('async', this.dialect, session, this.schema);
		try {
			const result = await transaction(tx);
			await libsqlTx.commit();
			return result;
		} catch (err) {
			await libsqlTx.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/libsql/session.ts.
Where is transaction() defined?
transaction() is defined in drizzle-orm/src/libsql/session.ts at line 107.
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