Home / Class/ GenerateCity Class — drizzle-orm Architecture

GenerateCity Class — drizzle-orm Architecture

Architecture documentation for the GenerateCity class in Generators.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  5a8bf5f4_4c4f_2a7c_f3e4_c46af6a1c1db["GenerateCity"]
  e5cee001_0354_7e76_ef0a_06dca71dc8ce["Generators.ts"]
  5a8bf5f4_4c4f_2a7c_f3e4_c46af6a1c1db -->|defined in| e5cee001_0354_7e76_ef0a_06dca71dc8ce
  6f86999c_478e_45f7_fb4e_ac5d3a3436e1["init()"]
  5a8bf5f4_4c4f_2a7c_f3e4_c46af6a1c1db -->|method| 6f86999c_478e_45f7_fb4e_ac5d3a3436e1
  4df4806b_5d52_8979_ac2f_0381eb990493["generate()"]
  5a8bf5f4_4c4f_2a7c_f3e4_c46af6a1c1db -->|method| 4df4806b_5d52_8979_ac2f_0381eb990493

Relationship Graph

Source Code

drizzle-seed/src/services/Generators.ts lines 2337–2372

export class GenerateCity extends AbstractGenerator<{
	isUnique?: boolean;
	arraySize?: number;
}> {
	static override readonly entityKind: string = 'GenerateCity';

	private state: {
		rng: prand.RandomGenerator;
	} | undefined;
	override uniqueVersionOfGen = GenerateUniqueCity;

	override init({ count, seed }: { count: number; seed: number }) {
		super.init({ count, seed });

		const rng = prand.xoroshiro128plus(seed);

		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}.`,
			);
		}

		this.state = { rng };
	}

	generate() {
		if (this.state === undefined) {
			throw new Error('state is not defined.');
		}

		let idx;
		[idx, this.state.rng] = prand.uniformIntDistribution(0, cityNames.length - 1, this.state.rng);

		return cityNames[idx];
	}
}

Domain

Frequently Asked Questions

What is the GenerateCity class?
GenerateCity is a class in the drizzle-orm codebase, defined in drizzle-seed/src/services/Generators.ts.
Where is GenerateCity defined?
GenerateCity is defined in drizzle-seed/src/services/Generators.ts at line 2337.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free