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

constructor() — drizzle-orm Function Reference

Architecture documentation for the constructor() function in db.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  5baa28d9_1767_f500_f6a1_4fc11896ce6a["constructor()"]
  10fbad18_129f_69a2_7ce3_79ea63dcf5d7["MySqlDatabase"]
  5baa28d9_1767_f500_f6a1_4fc11896ce6a -->|defined in| 10fbad18_129f_69a2_7ce3_79ea63dcf5d7
  68cf8bf4_2ee3_8fcf_5f5e_5ce21942f7b5["constructor()"]
  5baa28d9_1767_f500_f6a1_4fc11896ce6a -->|calls| 68cf8bf4_2ee3_8fcf_5f5e_5ce21942f7b5
  style 5baa28d9_1767_f500_f6a1_4fc11896ce6a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-orm/src/mysql-core/db.ts lines 54–90

	constructor(
		/** @internal */
		readonly dialect: MySqlDialect,
		/** @internal */
		readonly session: MySqlSession<any, any, any, any>,
		schema: RelationalSchemaConfig<TSchema> | undefined,
		protected readonly mode: Mode,
	) {
		this._ = schema
			? {
				schema: schema.schema,
				fullSchema: schema.fullSchema as TFullSchema,
				tableNamesMap: schema.tableNamesMap,
			}
			: {
				schema: undefined,
				fullSchema: {} as TFullSchema,
				tableNamesMap: {},
			};
		this.query = {} as typeof this['query'];
		if (this._.schema) {
			for (const [tableName, columns] of Object.entries(this._.schema)) {
				(this.query as MySqlDatabase<TQueryResult, TPreparedQueryHKT, Record<string, any>>['query'])[tableName] =
					new RelationalQueryBuilder(
						schema!.fullSchema,
						this._.schema,
						this._.tableNamesMap,
						schema!.fullSchema[tableName] as MySqlTable,
						columns,
						dialect,
						session,
						this.mode,
					);
			}
		}
		this.$cache = { invalidate: async (_params: any) => {} };
	}

Domain

Subdomains

Frequently Asked Questions

What does constructor() do?
constructor() is a function in the drizzle-orm codebase, defined in drizzle-orm/src/mysql-core/db.ts.
Where is constructor() defined?
constructor() is defined in drizzle-orm/src/mysql-core/db.ts at line 54.
What does constructor() call?
constructor() calls 1 function(s): constructor.

Analyze Your Own Codebase

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

Try Supermodel Free