Home / Class/ ExpoSQLiteSession Class — drizzle-orm Architecture

ExpoSQLiteSession Class — drizzle-orm Architecture

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

Entity Profile

Dependency Diagram

graph TD
  33ba6b18_96d6_f163_e48c_66df08078cf2["ExpoSQLiteSession"]
  ddcc8973_fc9e_23b4_1e3c_d3ff67e9b7e4["session.ts"]
  33ba6b18_96d6_f163_e48c_66df08078cf2 -->|defined in| ddcc8973_fc9e_23b4_1e3c_d3ff67e9b7e4
  1dec9a5b_930a_986f_f08e_ace976bb00e2["constructor()"]
  33ba6b18_96d6_f163_e48c_66df08078cf2 -->|method| 1dec9a5b_930a_986f_f08e_ace976bb00e2
  ce33c5eb_1304_efc2_cf48_e25d6d750159["prepareQuery()"]
  33ba6b18_96d6_f163_e48c_66df08078cf2 -->|method| ce33c5eb_1304_efc2_cf48_e25d6d750159
  0c2b387a_3962_23fd_6027_3006fc4626b5["transaction()"]
  33ba6b18_96d6_f163_e48c_66df08078cf2 -->|method| 0c2b387a_3962_23fd_6027_3006fc4626b5

Relationship Graph

Source Code

drizzle-orm/src/expo-sqlite/session.ts lines 25–77

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

	private logger: Logger;

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

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

	override transaction<T>(
		transaction: (tx: ExpoSQLiteTransaction<TFullSchema, TSchema>) => T,
		config: SQLiteTransactionConfig = {},
	): T {
		const tx = new ExpoSQLiteTransaction('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

Frequently Asked Questions

What is the ExpoSQLiteSession class?
ExpoSQLiteSession is a class in the drizzle-orm codebase, defined in drizzle-orm/src/expo-sqlite/session.ts.
Where is ExpoSQLiteSession defined?
ExpoSQLiteSession is defined in drizzle-orm/src/expo-sqlite/session.ts at line 25.

Analyze Your Own Codebase

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

Try Supermodel Free