GenerateFirstName Class — drizzle-orm Architecture
Architecture documentation for the GenerateFirstName class in Generators.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 007bbe97_e95a_7992_8a4e_54794d770b0c["GenerateFirstName"] e5cee001_0354_7e76_ef0a_06dca71dc8ce["Generators.ts"] 007bbe97_e95a_7992_8a4e_54794d770b0c -->|defined in| e5cee001_0354_7e76_ef0a_06dca71dc8ce c71f8427_32e4_9928_bce9_58a871f9ec57["init()"] 007bbe97_e95a_7992_8a4e_54794d770b0c -->|method| c71f8427_32e4_9928_bce9_58a871f9ec57 91e97382_f082_4ab1_034d_ca8ce0904bf9["generate()"] 007bbe97_e95a_7992_8a4e_54794d770b0c -->|method| 91e97382_f082_4ab1_034d_ca8ce0904bf9
Relationship Graph
Source Code
drizzle-seed/src/services/Generators.ts lines 1559–1597
export class GenerateFirstName extends AbstractGenerator<{
isUnique?: boolean;
arraySize?: number;
}> {
static override readonly entityKind: string = 'GenerateFirstName';
override timeSpent: number = 0;
private state: {
rng: prand.RandomGenerator;
} | undefined;
override uniqueVersionOfGen = GenerateUniqueFirstName;
override init({ count, seed }: { count: number; seed: number }) {
super.init({ count, seed });
const rng = prand.xoroshiro128plus(seed);
if (this.stringLength !== undefined && this.stringLength < maxFirstNameLength) {
throw new Error(
`You can't use first name generator with a db column length restriction of ${this.stringLength}. Set the maximum string length to at least ${maxFirstNameLength}.`,
);
}
this.state = { rng };
}
generate() {
if (this.state === undefined) {
throw new Error('state is not defined.');
}
// logic for this generator
// names dataset contains about 30000 unique names.
let idx: number;
[idx, this.state.rng] = prand.uniformIntDistribution(0, firstNames.length - 1, this.state.rng);
return firstNames[idx] as string;
}
}
Domain
Defined In
Source
Frequently Asked Questions
What is the GenerateFirstName class?
GenerateFirstName is a class in the drizzle-orm codebase, defined in drizzle-seed/src/services/Generators.ts.
Where is GenerateFirstName defined?
GenerateFirstName is defined in drizzle-seed/src/services/Generators.ts at line 1559.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free