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 75bd2780_4502_b790_c39c_65e09a1659d8["ForeignKeyBuilder"] fab980e5_64f0_d7af_6cbf_9d6014d326a4["foreign-keys.ts"] 75bd2780_4502_b790_c39c_65e09a1659d8 -->|defined in| fab980e5_64f0_d7af_6cbf_9d6014d326a4 7d116062_7545_b31c_bcfe_ddad94093ae9["constructor()"] 75bd2780_4502_b790_c39c_65e09a1659d8 -->|method| 7d116062_7545_b31c_bcfe_ddad94093ae9 4349e750_132c_5b1b_8ac7_315cea051f98["onUpdate()"] 75bd2780_4502_b790_c39c_65e09a1659d8 -->|method| 4349e750_132c_5b1b_8ac7_315cea051f98 7ce18ea3_3394_261b_e457_365e17f34ccb["onDelete()"] 75bd2780_4502_b790_c39c_65e09a1659d8 -->|method| 7ce18ea3_3394_261b_e457_365e17f34ccb 59de575a_25ac_be03_bf14_ab56b56c8e21["build()"] 75bd2780_4502_b790_c39c_65e09a1659d8 -->|method| 59de575a_25ac_be03_bf14_ab56b56c8e21
Relationship Graph
Source Code
drizzle-orm/src/sqlite-core/foreign-keys.ts lines 15–67
export class ForeignKeyBuilder {
static readonly [entityKind]: string = 'SQLiteForeignKeyBuilder';
declare _: {
brand: 'SQLiteForeignKeyBuilder';
foreignTableName: 'TForeignTableName';
};
/** @internal */
reference: Reference;
/** @internal */
_onUpdate: UpdateDeleteAction | undefined;
/** @internal */
_onDelete: UpdateDeleteAction | undefined;
constructor(
config: () => {
name?: string;
columns: SQLiteColumn[];
foreignColumns: SQLiteColumn[];
},
actions?: {
onUpdate?: UpdateDeleteAction;
onDelete?: UpdateDeleteAction;
} | undefined,
) {
this.reference = () => {
const { name, columns, foreignColumns } = config();
return { name, columns, foreignTable: foreignColumns[0]!.table as SQLiteTable, foreignColumns };
};
if (actions) {
this._onUpdate = actions.onUpdate;
this._onDelete = actions.onDelete;
}
}
onUpdate(action: UpdateDeleteAction): this {
this._onUpdate = action;
return this;
}
onDelete(action: UpdateDeleteAction): this {
this._onDelete = action;
return this;
}
/** @internal */
build(table: SQLiteTable): 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/sqlite-core/foreign-keys.ts.
Where is ForeignKeyBuilder defined?
ForeignKeyBuilder is defined in drizzle-orm/src/sqlite-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