Home / Function/ generate() — drizzle-orm Function Reference

generate() — drizzle-orm Function Reference

Architecture documentation for the generate() function in Generators.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  208c6f9f_5d31_c136_836a_98eea845da47["generate()"]
  5cbcdb32_076c_3e13_9eda_e9facd30f1c6["GenerateUUID"]
  208c6f9f_5d31_c136_836a_98eea845da47 -->|defined in| 5cbcdb32_076c_3e13_9eda_e9facd30f1c6
  style 208c6f9f_5d31_c136_836a_98eea845da47 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-seed/src/services/Generators.ts lines 1529–1556

	generate() {
		if (this.state === undefined) {
			throw new Error('state is not defined.');
		}
		// TODO generate uuid using string generator
		const stringChars = '1234567890abcdef';
		let idx: number,
			currStr: string;
		const strLength = 36;

		// uuid v4
		const uuidTemplate = '########-####-4###-####-############';
		currStr = '';
		for (let i = 0; i < strLength; i++) {
			[idx, this.state.rng] = prand.uniformIntDistribution(
				0,
				stringChars.length - 1,
				this.state.rng,
			);

			if (uuidTemplate[i] === '#') {
				currStr += stringChars[idx];
				continue;
			}
			currStr += uuidTemplate[i];
		}
		return currStr;
	}

Domain

Subdomains

Frequently Asked Questions

What does generate() do?
generate() is a function in the drizzle-orm codebase, defined in drizzle-seed/src/services/Generators.ts.
Where is generate() defined?
generate() is defined in drizzle-seed/src/services/Generators.ts at line 1529.

Analyze Your Own Codebase

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

Try Supermodel Free