Home / Class/ SQLiteBunSession Class — drizzle-orm Architecture

SQLiteBunSession Class — drizzle-orm Architecture

Architecture documentation for the SQLiteBunSession class in session.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  02d0c510_ed76_17a4_347a_0a7ad3ef5c35["SQLiteBunSession"]
  a33b9761_e026_5d23_a559_f5bba879c2dd["session.ts"]
  02d0c510_ed76_17a4_347a_0a7ad3ef5c35 -->|defined in| a33b9761_e026_5d23_a559_f5bba879c2dd
  6ee5eeb1_32c9_714f_ace7_e996e04fad11["constructor()"]
  02d0c510_ed76_17a4_347a_0a7ad3ef5c35 -->|method| 6ee5eeb1_32c9_714f_ace7_e996e04fad11
  3b67b382_340c_ed06_092e_15e079d00ee7["exec()"]
  02d0c510_ed76_17a4_347a_0a7ad3ef5c35 -->|method| 3b67b382_340c_ed06_092e_15e079d00ee7
  47f98000_a2ff_230d_54ce_8b4f47751090["prepareQuery()"]
  02d0c510_ed76_17a4_347a_0a7ad3ef5c35 -->|method| 47f98000_a2ff_230d_54ce_8b4f47751090
  33852796_71eb_674e_24b2_c4afc4cd08de["transaction()"]
  02d0c510_ed76_17a4_347a_0a7ad3ef5c35 -->|method| 33852796_71eb_674e_24b2_c4afc4cd08de

Relationship Graph

Source Code

drizzle-orm/src/bun-sqlite/session.ts lines 27–80

export class SQLiteBunSession<
	TFullSchema extends Record<string, unknown>,
	TSchema extends TablesRelationalConfig,
> extends SQLiteSession<'sync', void, TFullSchema, TSchema> {
	static override readonly [entityKind]: string = 'SQLiteBunSession';

	private logger: Logger;

	constructor(
		private client: Database,
		dialect: SQLiteSyncDialect,
		private schema: RelationalSchemaConfig<TSchema> | undefined,
		options: SQLiteBunSessionOptions = {},
	) {
		super(dialect);
		this.logger = options.logger ?? new NoopLogger();
	}

	exec(query: string): void {
		this.client.exec(query);
	}

	prepareQuery<T extends Omit<PreparedQueryConfig, 'run'>>(
		query: Query,
		fields: SelectedFieldsOrdered | undefined,
		executeMethod: SQLiteExecuteMethod,
		isResponseInArrayMode: boolean,
		customResultMapper?: (rows: unknown[][]) => unknown,
	): PreparedQuery<T> {
		const stmt = this.client.prepare(query.sql);
		return new PreparedQuery(
			stmt,
			query,
			this.logger,
			fields,
			executeMethod,
			isResponseInArrayMode,
			customResultMapper,
		);
	}

	override transaction<T>(
		transaction: (tx: SQLiteBunTransaction<TFullSchema, TSchema>) => T,
		config: SQLiteTransactionConfig = {},
	): T {
		const tx = new SQLiteBunTransaction('sync', this.dialect, this, this.schema);
		let result: T | undefined;
		const nativeTx = this.client.transaction(() => {
			result = transaction(tx);
		});
		nativeTx[config.behavior ?? 'deferred']();
		return result!;
	}
}

Domain

Frequently Asked Questions

What is the SQLiteBunSession class?
SQLiteBunSession is a class in the drizzle-orm codebase, defined in drizzle-orm/src/bun-sqlite/session.ts.
Where is SQLiteBunSession defined?
SQLiteBunSession is defined in drizzle-orm/src/bun-sqlite/session.ts at line 27.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free