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
  8c3dea3d_33e9_5815_012b_c19666b49b2a["constructor()"]
  9f85cd22_fd1d_a3c9_2e3f_f17ef323455e["BaseSQLiteDatabase"]
  8c3dea3d_33e9_5815_012b_c19666b49b2a -->|defined in| 9f85cd22_fd1d_a3c9_2e3f_f17ef323455e
  e2b79bec_664a_4ef1_44f2_965fb33bde1d["constructor()"]
  8c3dea3d_33e9_5815_012b_c19666b49b2a -->|calls| e2b79bec_664a_4ef1_44f2_965fb33bde1d
  style 8c3dea3d_33e9_5815_012b_c19666b49b2a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-orm/src/sqlite-core/db.ts lines 52–90

	constructor(
		private resultKind: TResultKind,
		/** @internal */
		readonly dialect: { sync: SQLiteSyncDialect; async: SQLiteAsyncDialect }[TResultKind],
		/** @internal */
		readonly session: SQLiteSession<TResultKind, TRunResult, TFullSchema, TSchema>,
		schema: RelationalSchemaConfig<TSchema> | undefined,
	) {
		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'];
		const query = this.query as {
			[K in keyof TSchema]: RelationalQueryBuilder<TResultKind, TFullSchema, TSchema, TSchema[K]>;
		};
		if (this._.schema) {
			for (const [tableName, columns] of Object.entries(this._.schema)) {
				query[tableName as keyof TSchema] = new RelationalQueryBuilder(
					resultKind,
					schema!.fullSchema,
					this._.schema,
					this._.tableNamesMap,
					schema!.fullSchema[tableName] as SQLiteTable,
					columns,
					dialect,
					session as SQLiteSession<any, any, any, any> as any,
				) as typeof query[keyof TSchema];
			}
		}
		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/sqlite-core/db.ts.
Where is constructor() defined?
constructor() is defined in drizzle-orm/src/sqlite-core/db.ts at line 52.
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