unique-constraint.ts — drizzle-orm Source File
Architecture documentation for unique-constraint.ts, a typescript file in the drizzle-orm codebase. 4 imports, 3 dependents.
Entity Profile
Dependency Diagram
graph LR b9679e1e_3f87_26cc_50d3_ac82b21fefe5["unique-constraint.ts"] c2ee5a75_b49e_5e5a_3712_97b1b67b4a7b["index.ts"] b9679e1e_3f87_26cc_50d3_ac82b21fefe5 --> c2ee5a75_b49e_5e5a_3712_97b1b67b4a7b 3c5f95cc_22b6_3d0d_d9be_3e274450e9e7["table.ts"] b9679e1e_3f87_26cc_50d3_ac82b21fefe5 --> 3c5f95cc_22b6_3d0d_d9be_3e274450e9e7 27705a9d_afe9_57dd_8c97_e52d8a67d426["entity.ts"] b9679e1e_3f87_26cc_50d3_ac82b21fefe5 --> 27705a9d_afe9_57dd_8c97_e52d8a67d426 05fb227e_0b02_2bf4_175f_8e70216a34a7["table.utils.ts"] b9679e1e_3f87_26cc_50d3_ac82b21fefe5 --> 05fb227e_0b02_2bf4_175f_8e70216a34a7 835b37b8_5537_93b3_6081_c47371e60b11["common.ts"] 835b37b8_5537_93b3_6081_c47371e60b11 --> b9679e1e_3f87_26cc_50d3_ac82b21fefe5 3c5f95cc_22b6_3d0d_d9be_3e274450e9e7["table.ts"] 3c5f95cc_22b6_3d0d_d9be_3e274450e9e7 --> b9679e1e_3f87_26cc_50d3_ac82b21fefe5 ae5f6568_e61c_e2e0_88cb_92eabc9ba98e["utils.ts"] ae5f6568_e61c_e2e0_88cb_92eabc9ba98e --> b9679e1e_3f87_26cc_50d3_ac82b21fefe5 style b9679e1e_3f87_26cc_50d3_ac82b21fefe5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { entityKind } from '~/entity.ts';
import { TableName } from '~/table.utils.ts';
import type { SingleStoreColumn } from './columns/index.ts';
import type { SingleStoreTable } from './table.ts';
export function unique(name?: string): UniqueOnConstraintBuilder {
return new UniqueOnConstraintBuilder(name);
}
export function uniqueKeyName(table: SingleStoreTable, columns: string[]) {
return `${table[TableName]}_${columns.join('_')}_unique`;
}
export class UniqueConstraintBuilder {
static readonly [entityKind]: string = 'SingleStoreUniqueConstraintBuilder';
/** @internal */
columns: SingleStoreColumn[];
constructor(
columns: SingleStoreColumn[],
private name?: string,
) {
this.columns = columns;
}
/** @internal */
build(table: SingleStoreTable): UniqueConstraint {
return new UniqueConstraint(table, this.columns, this.name);
}
}
export class UniqueOnConstraintBuilder {
static readonly [entityKind]: string = 'SingleStoreUniqueOnConstraintBuilder';
/** @internal */
name?: string;
constructor(
name?: string,
) {
this.name = name;
}
on(...columns: [SingleStoreColumn, ...SingleStoreColumn[]]) {
return new UniqueConstraintBuilder(columns, this.name);
}
}
export class UniqueConstraint {
static readonly [entityKind]: string = 'SingleStoreUniqueConstraint';
readonly columns: SingleStoreColumn[];
readonly name?: string;
readonly nullsNotDistinct: boolean = false;
constructor(readonly table: SingleStoreTable, columns: SingleStoreColumn[], name?: string) {
this.columns = columns;
this.name = name ?? uniqueKeyName(this.table, this.columns.map((column) => column.name));
}
getName() {
return this.name;
}
}
Domain
Subdomains
Functions
Imported By
Source
Frequently Asked Questions
What does unique-constraint.ts do?
unique-constraint.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 unique-constraint.ts?
unique-constraint.ts defines 2 function(s): unique, uniqueKeyName.
What does unique-constraint.ts depend on?
unique-constraint.ts imports 4 module(s): entity.ts, index.ts, table.ts, table.utils.ts.
What files import unique-constraint.ts?
unique-constraint.ts is imported by 3 file(s): common.ts, table.ts, utils.ts.
Where is unique-constraint.ts in the architecture?
unique-constraint.ts is located at drizzle-orm/src/singlestore-core/unique-constraint.ts (domain: DrizzleORM, subdomain: DatabaseDrivers, directory: drizzle-orm/src/singlestore-core).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free