BetterSQLiteSession Class — drizzle-orm Architecture
Architecture documentation for the BetterSQLiteSession class in session.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 14351328_0bb3_a023_1777_c1cf2bd65b9a["BetterSQLiteSession"] 3e7817ff_62e3_124e_fc75_14f2f00d713e["session.ts"] 14351328_0bb3_a023_1777_c1cf2bd65b9a -->|defined in| 3e7817ff_62e3_124e_fc75_14f2f00d713e 3910638f_c3a5_d9f6_3cab_b956135497da["constructor()"] 14351328_0bb3_a023_1777_c1cf2bd65b9a -->|method| 3910638f_c3a5_d9f6_3cab_b956135497da c382949b_54f5_62a5_6ab0_5d0ef19c1c88["prepareQuery()"] 14351328_0bb3_a023_1777_c1cf2bd65b9a -->|method| c382949b_54f5_62a5_6ab0_5d0ef19c1c88 29edfd58_2df2_c393_6f6e_4c7ba868b327["transaction()"] 14351328_0bb3_a023_1777_c1cf2bd65b9a -->|method| 29edfd58_2df2_c393_6f6e_4c7ba868b327
Relationship Graph
Source Code
drizzle-orm/src/better-sqlite3/session.ts lines 28–83
export class BetterSQLiteSession<
TFullSchema extends Record<string, unknown>,
TSchema extends TablesRelationalConfig,
> extends SQLiteSession<'sync', RunResult, TFullSchema, TSchema> {
static override readonly [entityKind]: string = 'BetterSQLiteSession';
private logger: Logger;
private cache: Cache;
constructor(
private client: Database,
dialect: SQLiteSyncDialect,
private schema: RelationalSchemaConfig<TSchema> | undefined,
options: BetterSQLiteSessionOptions = {},
) {
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,
): PreparedQuery<T> {
const stmt = this.client.prepare(query.sql);
return new PreparedQuery(
stmt,
query,
this.logger,
this.cache,
queryMetadata,
cacheConfig,
fields,
executeMethod,
isResponseInArrayMode,
customResultMapper,
);
}
override transaction<T>(
transaction: (tx: BetterSQLiteTransaction<TFullSchema, TSchema>) => T,
config: SQLiteTransactionConfig = {},
): T {
const tx = new BetterSQLiteTransaction('sync', this.dialect, this, this.schema);
const nativeTx = this.client.transaction(transaction);
return nativeTx[config.behavior ?? 'deferred'](tx);
}
}
Domain
Defined In
Source
Frequently Asked Questions
What is the BetterSQLiteSession class?
BetterSQLiteSession is a class in the drizzle-orm codebase, defined in drizzle-orm/src/better-sqlite3/session.ts.
Where is BetterSQLiteSession defined?
BetterSQLiteSession is defined in drizzle-orm/src/better-sqlite3/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