GenerateUniqueLastName Class — drizzle-orm Architecture
Architecture documentation for the GenerateUniqueLastName class in Generators.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 78c441aa_f70b_cd58_66f5_65ef7c43aa07["GenerateUniqueLastName"] e5cee001_0354_7e76_ef0a_06dca71dc8ce["Generators.ts"] 78c441aa_f70b_cd58_66f5_65ef7c43aa07 -->|defined in| e5cee001_0354_7e76_ef0a_06dca71dc8ce ac6ab817_d245_8b0e_b426_a2af3e3478c6["init()"] 78c441aa_f70b_cd58_66f5_65ef7c43aa07 -->|method| ac6ab817_d245_8b0e_b426_a2af3e3478c6 17acc0de_1085_ba4f_14f7_03b241fe7624["generate()"] 78c441aa_f70b_cd58_66f5_65ef7c43aa07 -->|method| 17acc0de_1085_ba4f_14f7_03b241fe7624
Relationship Graph
Source Code
drizzle-seed/src/services/Generators.ts lines 1675–1710
export class GenerateUniqueLastName extends AbstractGenerator<{ isUnique?: boolean }> {
static override readonly entityKind: string = 'GenerateUniqueLastName';
private state: {
genIndicesObj: GenerateUniqueInt;
} | undefined;
public override isUnique = true;
override init({ count, seed }: { count: number; seed: number }) {
if (count > lastNames.length) {
throw new Error('count exceeds max number of unique last names.');
}
if (this.stringLength !== undefined && this.stringLength < maxLastNameLength) {
throw new Error(
`You can't use last name generator with a db column length restriction of ${this.stringLength}. Set the maximum string length to at least ${maxLastNameLength}.`,
);
}
const genIndicesObj = new GenerateUniqueInt({ minValue: 0, maxValue: lastNames.length - 1 });
genIndicesObj.init({ count, seed });
this.state = { genIndicesObj };
}
generate() {
if (this.state === undefined) {
throw new Error('state is not defined.');
}
const surnameIdx = this.state.genIndicesObj.generate() as number;
const surname = lastNames[surnameIdx] as string;
return surname;
}
}
Domain
Defined In
Source
Frequently Asked Questions
What is the GenerateUniqueLastName class?
GenerateUniqueLastName is a class in the drizzle-orm codebase, defined in drizzle-seed/src/services/Generators.ts.
Where is GenerateUniqueLastName defined?
GenerateUniqueLastName is defined in drizzle-seed/src/services/Generators.ts at line 1675.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free