Home / Class/ GenerateUniquePoint Class — drizzle-orm Architecture

GenerateUniquePoint Class — drizzle-orm Architecture

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

Entity Profile

Dependency Diagram

graph TD
  d3c26555_b4ef_74e6_71b2_78dfe207f1a6["GenerateUniquePoint"]
  e5cee001_0354_7e76_ef0a_06dca71dc8ce["Generators.ts"]
  d3c26555_b4ef_74e6_71b2_78dfe207f1a6 -->|defined in| e5cee001_0354_7e76_ef0a_06dca71dc8ce
  a10b2310_3a93_03d3_87e9_5334ee82975f["init()"]
  d3c26555_b4ef_74e6_71b2_78dfe207f1a6 -->|method| a10b2310_3a93_03d3_87e9_5334ee82975f
  8e2366b3_86f8_ed74_9783_95f97c716992["generate()"]
  d3c26555_b4ef_74e6_71b2_78dfe207f1a6 -->|method| 8e2366b3_86f8_ed74_9783_95f97c716992

Relationship Graph

Source Code

drizzle-seed/src/services/Generators.ts lines 2928–2978

export class GenerateUniquePoint extends AbstractGenerator<{
	minXValue?: number;
	maxXValue?: number;
	minYValue?: number;
	maxYValue?: number;
	isUnique?: boolean;
}> {
	static override readonly entityKind: string = 'GenerateUniquePoint';

	private state: {
		xCoordinateGen: GenerateUniqueNumber;
		yCoordinateGen: GenerateUniqueNumber;
	} | undefined;
	public override isUnique = true;

	override init({ count, seed }: { count: number; seed: number }) {
		const xCoordinateGen = new GenerateUniqueNumber({
			minValue: this.params.minXValue,
			maxValue: this.params.maxXValue,
			precision: 10,
		});
		xCoordinateGen.init({ count, seed });

		const yCoordinateGen = new GenerateUniqueNumber({
			minValue: this.params.minYValue,
			maxValue: this.params.maxYValue,
			precision: 10,
		});
		yCoordinateGen.init({ count, seed });

		this.state = { xCoordinateGen, yCoordinateGen };
	}

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

		const x = this.state.xCoordinateGen.generate();
		const y = this.state.yCoordinateGen.generate();

		if (this.dataType === 'json') {
			return { x, y };
		} else if (this.dataType === 'string') {
			return `[${x}, ${y}]`;
		} else {
			// if (this.dataType === "array")
			return [x, y];
		}
	}
}

Domain

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free