Home / File/ session.ts — drizzle-orm Source File

session.ts — drizzle-orm Source File

Architecture documentation for session.ts, a typescript file in the drizzle-orm codebase. 13 imports, 1 dependents.

File typescript DrizzleORM DatabaseDrivers 13 imports 1 dependents 3 classes

Entity Profile

Dependency Diagram

graph LR
  271f5ca2_4cd0_ab39_be04_a2370f5c940c["session.ts"]
  04633f6c_35dc_bba1_868c_c1d9d27cf52d["driver.ts"]
  271f5ca2_4cd0_ab39_be04_a2370f5c940c --> 04633f6c_35dc_bba1_868c_c1d9d27cf52d
  4509cca4_7fd9_2ecd_1b7c_1ef1c0ee30c4["cache.ts"]
  271f5ca2_4cd0_ab39_be04_a2370f5c940c --> 4509cca4_7fd9_2ecd_1b7c_1ef1c0ee30c4
  47a9c453_10f1_a759_6246_695fcce2b20a["types.ts"]
  271f5ca2_4cd0_ab39_be04_a2370f5c940c --> 47a9c453_10f1_a759_6246_695fcce2b20a
  27705a9d_afe9_57dd_8c97_e52d8a67d426["entity.ts"]
  271f5ca2_4cd0_ab39_be04_a2370f5c940c --> 27705a9d_afe9_57dd_8c97_e52d8a67d426
  220c512d_350b_24bf_2142_53ec35a980ac["logger.ts"]
  271f5ca2_4cd0_ab39_be04_a2370f5c940c --> 220c512d_350b_24bf_2142_53ec35a980ac
  65dc222f_bc11_439f_d65b_20d7052b24ec["dialect.ts"]
  271f5ca2_4cd0_ab39_be04_a2370f5c940c --> 65dc222f_bc11_439f_d65b_20d7052b24ec
  fa14e9c0_b73d_4bcb_463b_adf18df8a285["index.ts"]
  271f5ca2_4cd0_ab39_be04_a2370f5c940c --> fa14e9c0_b73d_4bcb_463b_adf18df8a285
  79ece9bc_4c30_3a6b_c173_2b7b1842a99b["select.types.ts"]
  271f5ca2_4cd0_ab39_be04_a2370f5c940c --> 79ece9bc_4c30_3a6b_c173_2b7b1842a99b
  0e227879_31b1_8596_726d_80119efbf846["session.ts"]
  271f5ca2_4cd0_ab39_be04_a2370f5c940c --> 0e227879_31b1_8596_726d_80119efbf846
  e4d6a0ab_9aa2_13a6_a2f1_58d94314c3f2["relations.ts"]
  271f5ca2_4cd0_ab39_be04_a2370f5c940c --> e4d6a0ab_9aa2_13a6_a2f1_58d94314c3f2
  be483a7f_d5d7_7a9b_9a13_44a4a6aafbbd["sql.ts"]
  271f5ca2_4cd0_ab39_be04_a2370f5c940c --> be483a7f_d5d7_7a9b_9a13_44a4a6aafbbd
  051cc2d2_fe6f_16df_aaec_3b341d2c2576["tracing.ts"]
  271f5ca2_4cd0_ab39_be04_a2370f5c940c --> 051cc2d2_fe6f_16df_aaec_3b341d2c2576
  ecce3253_1e75_a87f_27b3_ca87e81a3024["utils.ts"]
  271f5ca2_4cd0_ab39_be04_a2370f5c940c --> ecce3253_1e75_a87f_27b3_ca87e81a3024
  04633f6c_35dc_bba1_868c_c1d9d27cf52d["driver.ts"]
  04633f6c_35dc_bba1_868c_c1d9d27cf52d --> 271f5ca2_4cd0_ab39_be04_a2370f5c940c
  style 271f5ca2_4cd0_ab39_be04_a2370f5c940c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { type Cache, NoopCache } from '~/cache/core/cache.ts';
import type { WithCacheConfig } from '~/cache/core/types.ts';
import { entityKind } from '~/entity.ts';
import type { Logger } from '~/logger.ts';
import { NoopLogger } from '~/logger.ts';
import type { PgDialect } from '~/pg-core/dialect.ts';
import { PgTransaction } from '~/pg-core/index.ts';
import type { SelectedFieldsOrdered } from '~/pg-core/query-builders/select.types.ts';
import type { PgQueryResultHKT, PgTransactionConfig, PreparedQueryConfig } from '~/pg-core/session.ts';
import { PgPreparedQuery as PreparedQueryBase, PgSession } from '~/pg-core/session.ts';
import type { RelationalSchemaConfig, TablesRelationalConfig } from '~/relations.ts';
import type { QueryWithTypings } from '~/sql/sql.ts';
import { fillPlaceholders } from '~/sql/sql.ts';
import { tracer } from '~/tracing.ts';
import { type Assume, mapResultRow } from '~/utils.ts';
import type { RemoteCallback } from './driver.ts';

export interface PgRemoteSessionOptions {
	logger?: Logger;
	cache?: Cache;
}

export class PgRemoteSession<
	TFullSchema extends Record<string, unknown>,
	TSchema extends TablesRelationalConfig,
> extends PgSession<PgRemoteQueryResultHKT, TFullSchema, TSchema> {
	static override readonly [entityKind]: string = 'PgRemoteSession';

	private logger: Logger;
	private cache: Cache;

	constructor(
		private client: RemoteCallback,
		dialect: PgDialect,
		private schema: RelationalSchemaConfig<TSchema> | undefined,
		options: PgRemoteSessionOptions = {},
	) {
		super(dialect);
		this.logger = options.logger ?? new NoopLogger();
		this.cache = options.cache ?? new NoopCache();
	}

	prepareQuery<T extends PreparedQueryConfig>(
		query: QueryWithTypings,
		fields: SelectedFieldsOrdered | undefined,
		name: string | undefined,
		isResponseInArrayMode: boolean,
		customResultMapper?: (rows: unknown[][]) => T['execute'],
		queryMetadata?: {
			type: 'select' | 'update' | 'delete' | 'insert';
			tables: string[];
		},
		cacheConfig?: WithCacheConfig,
	): PreparedQuery<T> {
		return new PreparedQuery(
			this.client,
			query.sql,
			query.params,
			query.typings,
			this.logger,
// ... (110 more lines)

Domain

Subdomains

Dependencies

  • cache.ts
  • dialect.ts
  • driver.ts
  • entity.ts
  • index.ts
  • logger.ts
  • relations.ts
  • select.types.ts
  • session.ts
  • sql.ts
  • tracing.ts
  • types.ts
  • utils.ts

Frequently Asked Questions

What does session.ts do?
session.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleORM domain, DatabaseDrivers subdomain.
What does session.ts depend on?
session.ts imports 13 module(s): cache.ts, dialect.ts, driver.ts, entity.ts, index.ts, logger.ts, relations.ts, select.types.ts, and 5 more.
What files import session.ts?
session.ts is imported by 1 file(s): driver.ts.
Where is session.ts in the architecture?
session.ts is located at drizzle-orm/src/pg-proxy/session.ts (domain: DrizzleORM, subdomain: DatabaseDrivers, directory: drizzle-orm/src/pg-proxy).

Analyze Your Own Codebase

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

Try Supermodel Free