primary-keys.ts — drizzle-orm Source File
Architecture documentation for primary-keys.ts, a typescript file in the drizzle-orm codebase. 4 imports, 2 dependents.
Entity Profile
Dependency Diagram
graph LR 63d21212_2bf5_401e_92eb_15e737e0575b["primary-keys.ts"] e383fa18_3db6_3f2c_0ac0_30b5ced54ad6["index.ts"] 63d21212_2bf5_401e_92eb_15e737e0575b --> e383fa18_3db6_3f2c_0ac0_30b5ced54ad6 62c695d3_7eff_3822_db70_ce6b25ccdb04["table.ts"] 63d21212_2bf5_401e_92eb_15e737e0575b --> 62c695d3_7eff_3822_db70_ce6b25ccdb04 3982449f_087b_16c6_e2b7_ca7b5dd4f1b7["MySqlTable"] 63d21212_2bf5_401e_92eb_15e737e0575b --> 3982449f_087b_16c6_e2b7_ca7b5dd4f1b7 27705a9d_afe9_57dd_8c97_e52d8a67d426["entity.ts"] 63d21212_2bf5_401e_92eb_15e737e0575b --> 27705a9d_afe9_57dd_8c97_e52d8a67d426 62c695d3_7eff_3822_db70_ce6b25ccdb04["table.ts"] 62c695d3_7eff_3822_db70_ce6b25ccdb04 --> 63d21212_2bf5_401e_92eb_15e737e0575b af63b8b3_1221_118f_75ac_f0b56c078499["utils.ts"] af63b8b3_1221_118f_75ac_f0b56c078499 --> 63d21212_2bf5_401e_92eb_15e737e0575b style 63d21212_2bf5_401e_92eb_15e737e0575b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { entityKind } from '~/entity.ts';
import type { AnyMySqlColumn, MySqlColumn } from './columns/index.ts';
import { MySqlTable } from './table.ts';
export function primaryKey<
TTableName extends string,
TColumn extends AnyMySqlColumn<{ tableName: TTableName }>,
TColumns extends AnyMySqlColumn<{ tableName: TTableName }>[],
>(config: { name?: string; columns: [TColumn, ...TColumns] }): PrimaryKeyBuilder;
/**
* @deprecated: Please use primaryKey({ columns: [] }) instead of this function
* @param columns
*/
export function primaryKey<
TTableName extends string,
TColumns extends AnyMySqlColumn<{ tableName: TTableName }>[],
>(...columns: TColumns): PrimaryKeyBuilder;
export function primaryKey(...config: any) {
if (config[0].columns) {
return new PrimaryKeyBuilder(config[0].columns, config[0].name);
}
return new PrimaryKeyBuilder(config);
}
export class PrimaryKeyBuilder {
static readonly [entityKind]: string = 'MySqlPrimaryKeyBuilder';
/** @internal */
columns: MySqlColumn[];
/** @internal */
name?: string;
constructor(
columns: MySqlColumn[],
name?: string,
) {
this.columns = columns;
this.name = name;
}
/** @internal */
build(table: MySqlTable): PrimaryKey {
return new PrimaryKey(table, this.columns, this.name);
}
}
export class PrimaryKey {
static readonly [entityKind]: string = 'MySqlPrimaryKey';
readonly columns: MySqlColumn[];
readonly name?: string;
constructor(readonly table: MySqlTable, columns: MySqlColumn[], name?: string) {
this.columns = columns;
this.name = name;
}
getName(): string {
return this.name
?? `${this.table[MySqlTable.Symbol.Name]}_${this.columns.map((column) => column.name).join('_')}_pk`;
}
}
Domain
Subdomains
Functions
Classes
Dependencies
- MySqlTable
- entity.ts
- index.ts
- table.ts
Source
Frequently Asked Questions
What does primary-keys.ts do?
primary-keys.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleORM domain, SQLDialects subdomain.
What functions are defined in primary-keys.ts?
primary-keys.ts defines 1 function(s): primaryKey.
What does primary-keys.ts depend on?
primary-keys.ts imports 4 module(s): MySqlTable, entity.ts, index.ts, table.ts.
What files import primary-keys.ts?
primary-keys.ts is imported by 2 file(s): table.ts, utils.ts.
Where is primary-keys.ts in the architecture?
primary-keys.ts is located at drizzle-orm/src/mysql-core/primary-keys.ts (domain: DrizzleORM, subdomain: SQLDialects, directory: drizzle-orm/src/mysql-core).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free