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