ForeignKeyBuilder Class — drizzle-orm Architecture
Architecture documentation for the ForeignKeyBuilder class in foreign-keys.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD dbda35af_725c_bbfb_ce7e_01f35541cefa["ForeignKeyBuilder"] fe0bf683_1731_529c_f1b4_81cc9db56955["foreign-keys.ts"] dbda35af_725c_bbfb_ce7e_01f35541cefa -->|defined in| fe0bf683_1731_529c_f1b4_81cc9db56955 7b69d4ac_ec6e_2006_3fdf_59fc7b1d9171["constructor()"] dbda35af_725c_bbfb_ce7e_01f35541cefa -->|method| 7b69d4ac_ec6e_2006_3fdf_59fc7b1d9171 1aba56e8_9d6f_9f21_e683_4ad40b760383["onUpdate()"] dbda35af_725c_bbfb_ce7e_01f35541cefa -->|method| 1aba56e8_9d6f_9f21_e683_4ad40b760383 6dd70dff_f42d_9227_0dcf_7016f3931853["onDelete()"] dbda35af_725c_bbfb_ce7e_01f35541cefa -->|method| 6dd70dff_f42d_9227_0dcf_7016f3931853 0bbd128e_973f_216b_7dd7_fa95e1c47424["build()"] dbda35af_725c_bbfb_ce7e_01f35541cefa -->|method| 0bbd128e_973f_216b_7dd7_fa95e1c47424
Relationship Graph
Source Code
drizzle-orm/src/gel-core/foreign-keys.ts lines 15–62
export class ForeignKeyBuilder {
static readonly [entityKind]: string = 'GelForeignKeyBuilder';
/** @internal */
reference: Reference;
/** @internal */
_onUpdate: UpdateDeleteAction | undefined = 'no action';
/** @internal */
_onDelete: UpdateDeleteAction | undefined = 'no action';
constructor(
config: () => {
name?: string;
columns: GelColumn[];
foreignColumns: GelColumn[];
},
actions?: {
onUpdate?: UpdateDeleteAction;
onDelete?: UpdateDeleteAction;
} | undefined,
) {
this.reference = () => {
const { name, columns, foreignColumns } = config();
return { name, columns, foreignTable: foreignColumns[0]!.table as GelTable, foreignColumns };
};
if (actions) {
this._onUpdate = actions.onUpdate;
this._onDelete = actions.onDelete;
}
}
onUpdate(action: UpdateDeleteAction): this {
this._onUpdate = action === undefined ? 'no action' : action;
return this;
}
onDelete(action: UpdateDeleteAction): this {
this._onDelete = action === undefined ? 'no action' : action;
return this;
}
/** @internal */
build(table: GelTable): ForeignKey {
return new ForeignKey(table, this);
}
}
Domain
Defined In
Source
Frequently Asked Questions
What is the ForeignKeyBuilder class?
ForeignKeyBuilder is a class in the drizzle-orm codebase, defined in drizzle-orm/src/gel-core/foreign-keys.ts.
Where is ForeignKeyBuilder defined?
ForeignKeyBuilder is defined in drizzle-orm/src/gel-core/foreign-keys.ts at line 15.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free