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
  1b055623_11c1_d0e1_3dc5_77b47e620228["generate()"]
  b5a9bb6b_0e7d_a582_f835_8b9053eb2844["GenerateJson"]
  1b055623_11c1_d0e1_3dc5_77b47e620228 -->|defined in| b5a9bb6b_0e7d_a582_f835_8b9053eb2844
  style 1b055623_11c1_d0e1_3dc5_77b47e620228 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-seed/src/services/Generators.ts lines 1155–1201

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

		const visitedCountries: string[] = [];
		const email = this.state.emailGeneratorObj.generate();
		const name = this.state.nameGeneratorObj.generate();
		const isGraduated = this.state.booleanGeneratorObj.generate();
		const hasJob = this.state.booleanGeneratorObj.generate();
		const salary = this.state.salaryGeneratorObj.generate() as number;
		const startedWorking = this.state.dateGeneratorObj.generate() as string;
		const visitedCountriesNumber = this.state.visitedCountriesNumberGeneratorObj.generate() as number;

		const uniqueCountriesGeneratorObj = new GenerateUniqueCountry({});
		uniqueCountriesGeneratorObj.init({
			count: visitedCountriesNumber,
			seed: this.state.seed + i,
		});
		for (let j = 0; j < visitedCountriesNumber; j++) {
			visitedCountries.push(uniqueCountriesGeneratorObj.generate());
		}

		const returnJson = hasJob
			? {
				email,
				name,
				isGraduated,
				hasJob,
				salary,
				startedWorking,
				visitedCountries,
			}
			: {
				email,
				name,
				isGraduated,
				hasJob,
				visitedCountries,
			};

		if (this.dataType === 'string') {
			return JSON.stringify(returnJson);
		}

		return returnJson;
	}

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 1155.

Analyze Your Own Codebase

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

Try Supermodel Free