GenerateUniqueFullName Class — drizzle-orm Architecture
Architecture documentation for the GenerateUniqueFullName class in Generators.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 08a89c6b_073a_a5c7_87b0_8608d1a1a5cd["GenerateUniqueFullName"] e5cee001_0354_7e76_ef0a_06dca71dc8ce["Generators.ts"] 08a89c6b_073a_a5c7_87b0_8608d1a1a5cd -->|defined in| e5cee001_0354_7e76_ef0a_06dca71dc8ce 263692c5_cd3e_9855_ce60_ce25ae4b07ea["init()"] 08a89c6b_073a_a5c7_87b0_8608d1a1a5cd -->|method| 263692c5_cd3e_9855_ce60_ce25ae4b07ea 946e057a_77e3_ff27_6f71_7ef49999c1c0["generate()"] 08a89c6b_073a_a5c7_87b0_8608d1a1a5cd -->|method| 946e057a_77e3_ff27_6f71_7ef49999c1c0
Relationship Graph
Source Code
drizzle-seed/src/services/Generators.ts lines 1758–1821
export class GenerateUniqueFullName extends AbstractGenerator<{
isUnique?: boolean;
}> {
static override readonly entityKind: string = 'GenerateUniqueFullName';
private state: {
fullnameSet: Set<string>;
rng: prand.RandomGenerator;
} | undefined;
public override isUnique = true;
public override timeSpent = 0;
override init({ count, seed }: { count: number; seed: number }) {
const t0 = new Date();
const maxUniqueFullNamesNumber = firstNames.length * lastNames.length;
if (count > maxUniqueFullNamesNumber) {
throw new RangeError(
`count exceeds max number of unique full names(${maxUniqueFullNamesNumber}).`,
);
}
if (this.stringLength !== undefined && this.stringLength < (maxFirstNameLength + maxLastNameLength + 1)) {
throw new Error(
`You can't use full name generator with a db column length restriction of ${this.stringLength}. Set the maximum string length to at least ${
maxFirstNameLength + maxLastNameLength + 1
}.`,
);
}
const rng = prand.xoroshiro128plus(seed);
const fullnameSet = new Set<string>();
this.state = { rng, fullnameSet };
this.timeSpent += (Date.now() - t0.getTime()) / 1000;
}
generate() {
if (this.state === undefined) {
throw new Error('state is not defined.');
}
let fullname: string, name: string, surname: string, idx: number;
const t0 = new Date();
for (;;) {
[idx, this.state.rng] = prand.uniformIntDistribution(0, firstNames.length - 1, this.state.rng);
name = firstNames[idx] as string;
[idx, this.state.rng] = prand.uniformIntDistribution(0, lastNames.length - 1, this.state.rng);
surname = lastNames[idx] as string;
fullname = `${name} ${surname}`;
if (!this.state.fullnameSet.has(fullname)) {
this.state.fullnameSet.add(fullname);
break;
}
}
this.timeSpent += (Date.now() - t0.getTime()) / 1000;
return fullname;
}
}
Domain
Defined In
Source
Frequently Asked Questions
What is the GenerateUniqueFullName class?
GenerateUniqueFullName is a class in the drizzle-orm codebase, defined in drizzle-seed/src/services/Generators.ts.
Where is GenerateUniqueFullName defined?
GenerateUniqueFullName is defined in drizzle-seed/src/services/Generators.ts at line 1758.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free