PgliteSession Class — drizzle-orm Architecture
Architecture documentation for the PgliteSession class in session.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD f7a3a747_96d4_b9ca_d4cb_e28899a93b1c["PgliteSession"] f04e535e_b661_b4ac_5837_80cbf4e6ecba["session.ts"] f7a3a747_96d4_b9ca_d4cb_e28899a93b1c -->|defined in| f04e535e_b661_b4ac_5837_80cbf4e6ecba aa47825d_ab1c_9b7b_3454_c4e8bf9c564e["constructor()"] f7a3a747_96d4_b9ca_d4cb_e28899a93b1c -->|method| aa47825d_ab1c_9b7b_3454_c4e8bf9c564e a04c6868_1007_0360_a786_7d3963323647["prepareQuery()"] f7a3a747_96d4_b9ca_d4cb_e28899a93b1c -->|method| a04c6868_1007_0360_a786_7d3963323647 5b1a58f5_53e2_3a69_3995_04daf2482ea0["transaction()"] f7a3a747_96d4_b9ca_d4cb_e28899a93b1c -->|method| 5b1a58f5_53e2_3a69_3995_04daf2482ea0 632c21c2_d54d_6f66_38d7_a4c48c083b8e["count()"] f7a3a747_96d4_b9ca_d4cb_e28899a93b1c -->|method| 632c21c2_d54d_6f66_38d7_a4c48c083b8e
Relationship Graph
Source Code
drizzle-orm/src/pglite/session.ts lines 123–195
export class PgliteSession<
TFullSchema extends Record<string, unknown>,
TSchema extends TablesRelationalConfig,
> extends PgSession<PgliteQueryResultHKT, TFullSchema, TSchema> {
static override readonly [entityKind]: string = 'PgliteSession';
private logger: Logger;
private cache: Cache;
constructor(
private client: PgliteClient | Transaction,
dialect: PgDialect,
private schema: RelationalSchemaConfig<TSchema> | undefined,
private options: PgliteSessionOptions = {},
) {
super(dialect);
this.logger = options.logger ?? new NoopLogger();
this.cache = options.cache ?? new NoopCache();
}
prepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(
query: Query,
fields: SelectedFieldsOrdered | undefined,
name: string | undefined,
isResponseInArrayMode: boolean,
customResultMapper?: (rows: unknown[][]) => T['execute'],
queryMetadata?: {
type: 'select' | 'update' | 'delete' | 'insert';
tables: string[];
},
cacheConfig?: WithCacheConfig,
): PgPreparedQuery<T> {
return new PglitePreparedQuery(
this.client,
query.sql,
query.params,
this.logger,
this.cache,
queryMetadata,
cacheConfig,
fields,
name,
isResponseInArrayMode,
customResultMapper,
);
}
override async transaction<T>(
transaction: (tx: PgliteTransaction<TFullSchema, TSchema>) => Promise<T>,
config?: PgTransactionConfig | undefined,
): Promise<T> {
return (this.client as PgliteClient).transaction(async (client) => {
const session = new PgliteSession<TFullSchema, TSchema>(
client,
this.dialect,
this.schema,
this.options,
);
const tx = new PgliteTransaction<TFullSchema, TSchema>(this.dialect, session, this.schema);
if (config) {
await tx.setTransaction(config);
}
return transaction(tx);
}) as Promise<T>;
}
override async count(sql: SQL): Promise<number> {
const res = await this.execute<{ rows: [{ count: string }] }>(sql);
return Number(
res['rows'][0]['count'],
);
}
}
Domain
Defined In
Source
Frequently Asked Questions
What is the PgliteSession class?
PgliteSession is a class in the drizzle-orm codebase, defined in drizzle-orm/src/pglite/session.ts.
Where is PgliteSession defined?
PgliteSession is defined in drizzle-orm/src/pglite/session.ts at line 123.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free