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
  f9517c23_ad07_1f0a_cee0_d0251d6c8eb7["generate()"]
  3e04765f_7007_ae41_d8f4_854c3d007fed["GenerateCompanyName"]
  f9517c23_ad07_1f0a_cee0_d0251d6c8eb7 -->|defined in| 3e04765f_7007_ae41_d8f4_854c3d007fed
  b796adef_dfbc_ebaa_ea14_31e6339b630a["fillTemplate()"]
  f9517c23_ad07_1f0a_cee0_d0251d6c8eb7 -->|calls| b796adef_dfbc_ebaa_ea14_31e6339b630a
  style f9517c23_ad07_1f0a_cee0_d0251d6c8eb7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-seed/src/services/Generators.ts lines 2625–2657

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

		let templateIdx, idx, lastName, companyNameSuffix, companyName;
		[templateIdx, this.state.rng] = prand.uniformIntDistribution(0, this.state.templates.length - 1, this.state.rng);
		const templateObj = this.state.templates[templateIdx]!;

		if (templateObj.template === '#') {
			[idx, this.state.rng] = prand.uniformIntDistribution(0, lastNames.length - 1, this.state.rng);
			lastName = lastNames[idx];

			[idx, this.state.rng] = prand.uniformIntDistribution(0, companyNameSuffixes.length - 1, this.state.rng);
			companyNameSuffix = companyNameSuffixes[idx];

			companyName = `${lastName} ${companyNameSuffix}`;
			return companyName;
		}

		const values = [];
		for (let i = 0; i < templateObj.placeholdersCount; i++) {
			[idx, this.state.rng] = prand.uniformIntDistribution(0, lastNames.length - 1, this.state.rng);
			values.push(lastNames[idx]!);
		}

		companyName = fillTemplate({
			template: templateObj.template,
			values,
			placeholdersCount: templateObj.placeholdersCount,
		});
		return companyName;
	}

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 2625.
What does generate() call?
generate() calls 1 function(s): fillTemplate.

Analyze Your Own Codebase

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

Try Supermodel Free