primary-keys.ts — drizzle-orm Source File
Architecture documentation for primary-keys.ts, a typescript file in the drizzle-orm codebase. 4 imports, 3 dependents.
Entity Profile
Dependency Diagram
graph LR 87a357d2_c2ec_b04d_8912_3b8be2a92815["primary-keys.ts"] b5f68e91_0c18_4699_4724_dcbb5d28898e["index.ts"] 87a357d2_c2ec_b04d_8912_3b8be2a92815 --> b5f68e91_0c18_4699_4724_dcbb5d28898e 2d5c8884_973c_561c_def6_5e394ea36d1a["table.ts"] 87a357d2_c2ec_b04d_8912_3b8be2a92815 --> 2d5c8884_973c_561c_def6_5e394ea36d1a 960c33ed_4815_112a_43be_67b90cb1260f["PgTable"] 87a357d2_c2ec_b04d_8912_3b8be2a92815 --> 960c33ed_4815_112a_43be_67b90cb1260f 27705a9d_afe9_57dd_8c97_e52d8a67d426["entity.ts"] 87a357d2_c2ec_b04d_8912_3b8be2a92815 --> 27705a9d_afe9_57dd_8c97_e52d8a67d426 2d5c8884_973c_561c_def6_5e394ea36d1a["table.ts"] 2d5c8884_973c_561c_def6_5e394ea36d1a --> 87a357d2_c2ec_b04d_8912_3b8be2a92815 ce49a5a3_688d_ddce_fd32_28428e51cae2["utils.ts"] ce49a5a3_688d_ddce_fd32_28428e51cae2 --> 87a357d2_c2ec_b04d_8912_3b8be2a92815 2f47d090_425d_2e56_2395_4c4d912316f0["relations.ts"] 2f47d090_425d_2e56_2395_4c4d912316f0 --> 87a357d2_c2ec_b04d_8912_3b8be2a92815 style 87a357d2_c2ec_b04d_8912_3b8be2a92815 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { entityKind } from '~/entity.ts';
import type { AnyPgColumn, PgColumn } from './columns/index.ts';
import { PgTable } from './table.ts';
export function primaryKey<
TTableName extends string,
TColumn extends AnyPgColumn<{ tableName: TTableName }>,
TColumns extends AnyPgColumn<{ 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 AnyPgColumn<{ 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 = 'PgPrimaryKeyBuilder';
/** @internal */
columns: PgColumn[];
/** @internal */
name?: string;
constructor(
columns: PgColumn[],
name?: string,
) {
this.columns = columns;
this.name = name;
}
/** @internal */
build(table: PgTable): PrimaryKey {
return new PrimaryKey(table, this.columns, this.name);
}
}
export class PrimaryKey {
static readonly [entityKind]: string = 'PgPrimaryKey';
readonly columns: AnyPgColumn<{}>[];
readonly name?: string;
constructor(readonly table: PgTable, columns: AnyPgColumn<{}>[], name?: string) {
this.columns = columns;
this.name = name;
}
getName(): string {
return this.name ?? `${this.table[PgTable.Symbol.Name]}_${this.columns.map((column) => column.name).join('_')}_pk`;
}
}
Domain
Subdomains
Functions
Classes
Imported By
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, DatabaseDrivers 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): PgTable, entity.ts, index.ts, table.ts.
What files import primary-keys.ts?
primary-keys.ts is imported by 3 file(s): relations.ts, table.ts, utils.ts.
Where is primary-keys.ts in the architecture?
primary-keys.ts is located at drizzle-orm/src/pg-core/primary-keys.ts (domain: DrizzleORM, subdomain: DatabaseDrivers, directory: drizzle-orm/src/pg-core).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free