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