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 471611d2_cce2_4786_c10b_d1a110fdccc3["primary-keys.ts"] a2e1e4f4_2b6e_c197_a707_793466cb421f["index.ts"] 471611d2_cce2_4786_c10b_d1a110fdccc3 --> a2e1e4f4_2b6e_c197_a707_793466cb421f cbe7af57_41be_454d_306f_02d0e6f81949["table.ts"] 471611d2_cce2_4786_c10b_d1a110fdccc3 --> cbe7af57_41be_454d_306f_02d0e6f81949 2eedb6f7_d8cd_b386_c3b0_8585d8562d1d["GelTable"] 471611d2_cce2_4786_c10b_d1a110fdccc3 --> 2eedb6f7_d8cd_b386_c3b0_8585d8562d1d 27705a9d_afe9_57dd_8c97_e52d8a67d426["entity.ts"] 471611d2_cce2_4786_c10b_d1a110fdccc3 --> 27705a9d_afe9_57dd_8c97_e52d8a67d426 cbe7af57_41be_454d_306f_02d0e6f81949["table.ts"] cbe7af57_41be_454d_306f_02d0e6f81949 --> 471611d2_cce2_4786_c10b_d1a110fdccc3 9cb8488e_0ece_edef_af6a_5851d56cddda["utils.ts"] 9cb8488e_0ece_edef_af6a_5851d56cddda --> 471611d2_cce2_4786_c10b_d1a110fdccc3 style 471611d2_cce2_4786_c10b_d1a110fdccc3 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { entityKind } from '~/entity.ts';
import type { AnyGelColumn, GelColumn } from './columns/index.ts';
import { GelTable } from './table.ts';
export function primaryKey<
TTableName extends string,
TColumn extends AnyGelColumn<{ tableName: TTableName }>,
TColumns extends AnyGelColumn<{ 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 AnyGelColumn<{ 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 = 'GelPrimaryKeyBuilder';
/** @internal */
columns: GelColumn[];
/** @internal */
name?: string;
constructor(
columns: GelColumn[],
name?: string,
) {
this.columns = columns;
this.name = name;
}
/** @internal */
build(table: GelTable): PrimaryKey {
return new PrimaryKey(table, this.columns, this.name);
}
}
export class PrimaryKey {
static readonly [entityKind]: string = 'GelPrimaryKey';
readonly columns: AnyGelColumn<{}>[];
readonly name?: string;
constructor(readonly table: GelTable, columns: AnyGelColumn<{}>[], name?: string) {
this.columns = columns;
this.name = name;
}
getName(): string {
return this.name ?? `${this.table[GelTable.Symbol.Name]}_${this.columns.map((column) => column.name).join('_')}_pk`;
}
}
Domain
Subdomains
Functions
Classes
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, RelationalQuery 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): GelTable, 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/gel-core/primary-keys.ts (domain: DrizzleORM, subdomain: RelationalQuery, directory: drizzle-orm/src/gel-core).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free