Home / Class/ GenerateFullName Class — drizzle-orm Architecture

GenerateFullName Class — drizzle-orm Architecture

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

Entity Profile

Dependency Diagram

graph TD
  fee4fb82_30a9_ab8b_b634_e36f5235e99f["GenerateFullName"]
  e5cee001_0354_7e76_ef0a_06dca71dc8ce["Generators.ts"]
  fee4fb82_30a9_ab8b_b634_e36f5235e99f -->|defined in| e5cee001_0354_7e76_ef0a_06dca71dc8ce
  49edeffd_bff3_ade5_1b98_ff32d6b257b4["init()"]
  fee4fb82_30a9_ab8b_b634_e36f5235e99f -->|method| 49edeffd_bff3_ade5_1b98_ff32d6b257b4
  013c627a_b882_b3b5_1015_edeb0a7fbeb5["generate()"]
  fee4fb82_30a9_ab8b_b634_e36f5235e99f -->|method| 013c627a_b882_b3b5_1015_edeb0a7fbeb5

Relationship Graph

Source Code

drizzle-seed/src/services/Generators.ts lines 1712–1756

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

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

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

		const rng = prand.xoroshiro128plus(seed);

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

		this.state = { rng };
	}

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

		let idx: number;

		[idx, this.state.rng] = prand.uniformIntDistribution(0, firstNames.length - 1, this.state.rng);
		const name = firstNames[idx] as string;

		[idx, this.state.rng] = prand.uniformIntDistribution(0, lastNames.length - 1, this.state.rng);
		const surname = lastNames[idx] as string;

		const fullName = `${name} ${surname}`;

		return fullName;
	}
}

Domain

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free