Home / Function/ construct() — drizzle-orm Function Reference

construct() — drizzle-orm Function Reference

Architecture documentation for the construct() function in driver.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  2c9f0c0b_5d77_79ee_96f7_a24bf445c5c0["construct()"]
  d4882ed1_0e96_6210_f61b_425eb48edf20["driver.ts"]
  2c9f0c0b_5d77_79ee_96f7_a24bf445c5c0 -->|defined in| d4882ed1_0e96_6210_f61b_425eb48edf20
  34204185_d2a0_e4b6_9f5a_d4fcdf89b9b1["drizzle()"]
  34204185_d2a0_e4b6_9f5a_d4fcdf89b9b1 -->|calls| 2c9f0c0b_5d77_79ee_96f7_a24bf445c5c0
  7d4356ad_647c_27e8_a776_8e9b9e7cc890["mock()"]
  7d4356ad_647c_27e8_a776_8e9b9e7cc890 -->|calls| 2c9f0c0b_5d77_79ee_96f7_a24bf445c5c0
  style 2c9f0c0b_5d77_79ee_96f7_a24bf445c5c0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-orm/src/aws-data-api/pg/driver.ts lines 95–131

function construct<TSchema extends Record<string, unknown> = Record<string, never>>(
	client: AwsDataApiClient,
	config: DrizzleAwsDataApiPgConfig<TSchema>,
): AwsDataApiPgDatabase<TSchema> & {
	$client: AwsDataApiClient;
} {
	const dialect = new AwsPgDialect({ casing: config.casing });
	let logger;
	if (config.logger === true) {
		logger = new DefaultLogger();
	} else if (config.logger !== false) {
		logger = config.logger;
	}

	let schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined;
	if (config.schema) {
		const tablesConfig = extractTablesRelationalConfig(
			config.schema,
			createTableRelationsHelpers,
		);
		schema = {
			fullSchema: config.schema,
			schema: tablesConfig.tables,
			tableNamesMap: tablesConfig.tableNamesMap,
		};
	}

	const session = new AwsDataApiSession(client, dialect, schema, { ...config, logger, cache: config.cache }, undefined);
	const db = new AwsDataApiPgDatabase(dialect, session, schema as any);
	(<any> db).$client = client;
	(<any> db).$cache = config.cache;
	if ((<any> db).$cache) {
		(<any> db).$cache['invalidate'] = config.cache?.onMutate;
	}

	return db as any;
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does construct() do?
construct() is a function in the drizzle-orm codebase, defined in drizzle-orm/src/aws-data-api/pg/driver.ts.
Where is construct() defined?
construct() is defined in drizzle-orm/src/aws-data-api/pg/driver.ts at line 95.
What calls construct()?
construct() is called by 2 function(s): drizzle, mock.

Analyze Your Own Codebase

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

Try Supermodel Free