Home / Class/ GeneratePoint Class — drizzle-orm Architecture

GeneratePoint Class — drizzle-orm Architecture

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

Entity Profile

Dependency Diagram

graph TD
  e6fcd96f_7a66_731c_ec71_91cc0a1c3b6f["GeneratePoint"]
  e5cee001_0354_7e76_ef0a_06dca71dc8ce["Generators.ts"]
  e6fcd96f_7a66_731c_ec71_91cc0a1c3b6f -->|defined in| e5cee001_0354_7e76_ef0a_06dca71dc8ce
  d22a6f42_0ad4_9de7_3eaa_f98c12e33cbb["init()"]
  e6fcd96f_7a66_731c_ec71_91cc0a1c3b6f -->|method| d22a6f42_0ad4_9de7_3eaa_f98c12e33cbb
  396bd308_aa7b_689d_1393_9be2a925e54c["generate()"]
  e6fcd96f_7a66_731c_ec71_91cc0a1c3b6f -->|method| 396bd308_aa7b_689d_1393_9be2a925e54c

Relationship Graph

Source Code

drizzle-seed/src/services/Generators.ts lines 2873–2926

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

	private state: {
		xCoordinateGen: GenerateNumber;
		yCoordinateGen: GenerateNumber;
	} | undefined;
	override uniqueVersionOfGen = GenerateUniquePoint;

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

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

		const yCoordinateGen = new GenerateNumber({
			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 GeneratePoint class?
GeneratePoint is a class in the drizzle-orm codebase, defined in drizzle-seed/src/services/Generators.ts.
Where is GeneratePoint defined?
GeneratePoint is defined in drizzle-seed/src/services/Generators.ts at line 2873.

Analyze Your Own Codebase

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

Try Supermodel Free