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

driver.ts — drizzle-orm Source File

Architecture documentation for driver.ts, a typescript file in the drizzle-orm codebase. 11 imports, 0 dependents.

File typescript DrizzleORM RelationalQuery 11 imports 3 functions 2 classes

Entity Profile

Dependency Diagram

graph LR
  612dbe90_48c8_5f9e_1685_3ec048012649["driver.ts"]
  40439e01_0b0d_d1ca_8a6c_cc21c23b9ce0["session.ts"]
  612dbe90_48c8_5f9e_1685_3ec048012649 --> 40439e01_0b0d_d1ca_8a6c_cc21c23b9ce0
  7a5a243a_5865_a6b8_4241_75b36641bad7["GelDbSession"]
  612dbe90_48c8_5f9e_1685_3ec048012649 --> 7a5a243a_5865_a6b8_4241_75b36641bad7
  90067f6e_33cd_67c4_3575_3758cdacb6e2["gel"]
  612dbe90_48c8_5f9e_1685_3ec048012649 --> 90067f6e_33cd_67c4_3575_3758cdacb6e2
  363fdd67_2503_7ef7_e1f3_a1ef31694431["index.ts"]
  612dbe90_48c8_5f9e_1685_3ec048012649 --> 363fdd67_2503_7ef7_e1f3_a1ef31694431
  27705a9d_afe9_57dd_8c97_e52d8a67d426["entity.ts"]
  612dbe90_48c8_5f9e_1685_3ec048012649 --> 27705a9d_afe9_57dd_8c97_e52d8a67d426
  3cf3a844_1d86_022f_18d7_2417c28b80e5["db.ts"]
  612dbe90_48c8_5f9e_1685_3ec048012649 --> 3cf3a844_1d86_022f_18d7_2417c28b80e5
  f86d3f7c_7b46_5b9f_94e2_ac0a5f48d903["dialect.ts"]
  612dbe90_48c8_5f9e_1685_3ec048012649 --> f86d3f7c_7b46_5b9f_94e2_ac0a5f48d903
  90dfe595_29ab_0495_4263_3b19b4bb4d9b["session.ts"]
  612dbe90_48c8_5f9e_1685_3ec048012649 --> 90dfe595_29ab_0495_4263_3b19b4bb4d9b
  220c512d_350b_24bf_2142_53ec35a980ac["logger.ts"]
  612dbe90_48c8_5f9e_1685_3ec048012649 --> 220c512d_350b_24bf_2142_53ec35a980ac
  e4d6a0ab_9aa2_13a6_a2f1_58d94314c3f2["relations.ts"]
  612dbe90_48c8_5f9e_1685_3ec048012649 --> e4d6a0ab_9aa2_13a6_a2f1_58d94314c3f2
  ecce3253_1e75_a87f_27b3_ca87e81a3024["utils.ts"]
  612dbe90_48c8_5f9e_1685_3ec048012649 --> ecce3253_1e75_a87f_27b3_ca87e81a3024
  style 612dbe90_48c8_5f9e_1685_3ec048012649 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { type Client, type ConnectOptions, createClient } from 'gel';
import type { Cache } from '~/cache/core/index.ts';
import { entityKind } from '~/entity.ts';
import { GelDatabase } from '~/gel-core/db.ts';
import { GelDialect } from '~/gel-core/dialect.ts';
import type { GelQueryResultHKT } from '~/gel-core/session.ts';
import type { Logger } from '~/logger.ts';
import { DefaultLogger } from '~/logger.ts';
import {
	createTableRelationsHelpers,
	extractTablesRelationalConfig,
	type RelationalSchemaConfig,
	type TablesRelationalConfig,
} from '~/relations.ts';
import { type DrizzleConfig, isConfig } from '~/utils.ts';
import type { GelClient } from './session.ts';
import { GelDbSession } from './session.ts';

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

export class GelDriver {
	static readonly [entityKind]: string = 'GelDriver';

	constructor(
		private client: GelClient,
		private dialect: GelDialect,
		private options: GelDriverOptions = {},
	) {}

	createSession(
		schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined,
	): GelDbSession<Record<string, unknown>, TablesRelationalConfig> {
		return new GelDbSession(this.client, this.dialect, schema, {
			logger: this.options.logger,
			cache: this.options.cache,
		});
	}
}

export class GelJsDatabase<TSchema extends Record<string, unknown> = Record<string, never>>
	extends GelDatabase<GelQueryResultHKT, TSchema>
{
	static override readonly [entityKind]: string = 'GelJsDatabase';
}

function construct<
	TSchema extends Record<string, unknown> = Record<string, never>,
	TClient extends GelClient = GelClient,
>(
	client: TClient,
	config: DrizzleConfig<TSchema> = {},
): GelJsDatabase<TSchema> & {
	$client: GelClient extends TClient ? Client : TClient;
} {
	const dialect = new GelDialect({ casing: config.casing });
	let logger;
	if (config.logger === true) {
// ... (80 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does driver.ts do?
driver.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleORM domain, RelationalQuery subdomain.
What functions are defined in driver.ts?
driver.ts defines 3 function(s): construct, drizzle, mock.
What does driver.ts depend on?
driver.ts imports 11 module(s): GelDbSession, db.ts, dialect.ts, entity.ts, gel, index.ts, logger.ts, relations.ts, and 3 more.
Where is driver.ts in the architecture?
driver.ts is located at drizzle-orm/src/gel/driver.ts (domain: DrizzleORM, subdomain: RelationalQuery, directory: drizzle-orm/src/gel).

Analyze Your Own Codebase

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

Try Supermodel Free