OPSQLiteSession Class — drizzle-orm Architecture
Architecture documentation for the OPSQLiteSession class in session.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD a96c3d61_1d27_8a4f_e20c_2647f5908960["OPSQLiteSession"] 45f9aea4_1252_eb43_9fc8_0fff93550668["session.ts"] a96c3d61_1d27_8a4f_e20c_2647f5908960 -->|defined in| 45f9aea4_1252_eb43_9fc8_0fff93550668 39143895_bcae_6372_ef25_0a67bfaf6e8c["constructor()"] a96c3d61_1d27_8a4f_e20c_2647f5908960 -->|method| 39143895_bcae_6372_ef25_0a67bfaf6e8c f0c71bd7_5690_ddab_39d6_a7063cb11aed["prepareQuery()"] a96c3d61_1d27_8a4f_e20c_2647f5908960 -->|method| f0c71bd7_5690_ddab_39d6_a7063cb11aed 260a98d9_0f8b_1153_44a9_06abca8e13da["transaction()"] a96c3d61_1d27_8a4f_e20c_2647f5908960 -->|method| 260a98d9_0f8b_1153_44a9_06abca8e13da
Relationship Graph
Source Code
drizzle-orm/src/op-sqlite/session.ts lines 28–89
export class OPSQLiteSession<
TFullSchema extends Record<string, unknown>,
TSchema extends TablesRelationalConfig,
> extends SQLiteSession<'async', QueryResult, TFullSchema, TSchema> {
static override readonly [entityKind]: string = 'OPSQLiteSession';
private logger: Logger;
private cache: Cache;
constructor(
private client: OPSQLiteConnection,
dialect: SQLiteAsyncDialect,
private schema: RelationalSchemaConfig<TSchema> | undefined,
options: OPSQLiteSessionOptions = {},
) {
super(dialect);
this.logger = options.logger ?? new NoopLogger();
this.cache = options.cache ?? new NoopCache();
}
prepareQuery<T extends Omit<PreparedQueryConfig, 'run'>>(
query: Query,
fields: SelectedFieldsOrdered | undefined,
executeMethod: SQLiteExecuteMethod,
isResponseInArrayMode: boolean,
customResultMapper?: (rows: unknown[][]) => unknown,
queryMetadata?: {
type: 'select' | 'update' | 'delete' | 'insert';
tables: string[];
},
cacheConfig?: WithCacheConfig,
): OPSQLitePreparedQuery<T> {
return new OPSQLitePreparedQuery(
this.client,
query,
this.logger,
this.cache,
queryMetadata,
cacheConfig,
fields,
executeMethod,
isResponseInArrayMode,
customResultMapper,
);
}
override transaction<T>(
transaction: (tx: OPSQLiteTransaction<TFullSchema, TSchema>) => T,
config: SQLiteTransactionConfig = {},
): T {
const tx = new OPSQLiteTransaction('async', 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
Defined In
Source
Frequently Asked Questions
What is the OPSQLiteSession class?
OPSQLiteSession is a class in the drizzle-orm codebase, defined in drizzle-orm/src/op-sqlite/session.ts.
Where is OPSQLiteSession defined?
OPSQLiteSession is defined in drizzle-orm/src/op-sqlite/session.ts at line 28.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free