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

createJoin() — drizzle-orm Function Reference

Architecture documentation for the createJoin() function in update.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  68a4a459_8363_98af_dca7_6d21e784553e["createJoin()"]
  2554514b_4610_9aed_e6d5_669cd23017c0["SQLiteUpdateBase"]
  68a4a459_8363_98af_dca7_6d21e784553e -->|defined in| 2554514b_4610_9aed_e6d5_669cd23017c0
  style 68a4a459_8363_98af_dca7_6d21e784553e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-orm/src/sqlite-core/query-builders/update.ts lines 262–301

	private createJoin<TJoinType extends JoinType>(
		joinType: TJoinType,
	): SQLiteUpdateJoinFn<this> {
		return ((
			table: SQLiteTable | Subquery | SQLiteViewBase | SQL,
			on: ((updateTable: TTable, from: TFrom) => SQL | undefined) | SQL | undefined,
		) => {
			const tableName = getTableLikeName(table);

			if (typeof tableName === 'string' && this.config.joins.some((join) => join.alias === tableName)) {
				throw new Error(`Alias "${tableName}" is already used in this query`);
			}

			if (typeof on === 'function') {
				const from = this.config.from
					? is(table, SQLiteTable)
						? table[Table.Symbol.Columns]
						: is(table, Subquery)
						? table._.selectedFields
						: is(table, SQLiteViewBase)
						? table[ViewBaseConfig].selectedFields
						: undefined
					: undefined;
				on = on(
					new Proxy(
						this.config.table[Table.Symbol.Columns],
						new SelectionProxyHandler({ sqlAliasedBehavior: 'sql', sqlBehavior: 'sql' }),
					) as any,
					from && new Proxy(
						from,
						new SelectionProxyHandler({ sqlAliasedBehavior: 'sql', sqlBehavior: 'sql' }),
					) as any,
				);
			}

			this.config.joins.push({ on, table, joinType, alias: tableName });

			return this as any;
		}) as any;
	}

Domain

Subdomains

Frequently Asked Questions

What does createJoin() do?
createJoin() is a function in the drizzle-orm codebase, defined in drizzle-orm/src/sqlite-core/query-builders/update.ts.
Where is createJoin() defined?
createJoin() is defined in drizzle-orm/src/sqlite-core/query-builders/update.ts at line 262.

Analyze Your Own Codebase

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

Try Supermodel Free