Home / Class/ GenerateLastName Class — drizzle-orm Architecture

GenerateLastName Class — drizzle-orm Architecture

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

Entity Profile

Dependency Diagram

graph TD
  7a5d2913_c702_f1e3_d66b_592bafea0d9c["GenerateLastName"]
  e5cee001_0354_7e76_ef0a_06dca71dc8ce["Generators.ts"]
  7a5d2913_c702_f1e3_d66b_592bafea0d9c -->|defined in| e5cee001_0354_7e76_ef0a_06dca71dc8ce
  b134ebd9_e637_5004_09fa_34410c1a55c2["init()"]
  7a5d2913_c702_f1e3_d66b_592bafea0d9c -->|method| b134ebd9_e637_5004_09fa_34410c1a55c2
  0fbfa524_0676_66fd_5795_98813e5c1c24["generate()"]
  7a5d2913_c702_f1e3_d66b_592bafea0d9c -->|method| 0fbfa524_0676_66fd_5795_98813e5c1c24

Relationship Graph

Source Code

drizzle-seed/src/services/Generators.ts lines 1639–1673

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

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

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

		const rng = prand.xoroshiro128plus(seed);

		if (this.stringLength !== undefined && this.stringLength < maxLastNameLength) {
			throw new Error(
				`You can't use last name generator with a db column length restriction of ${this.stringLength}. Set the maximum string length to at least ${maxLastNameLength}.`,
			);
		}

		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, lastNames.length - 1, this.state.rng);
		return lastNames[idx];
	}
}

Domain

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free