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
  273c7454_c6f6_3f2e_89f6_885815c26847["generate()"]
  2b9767de_2ad4_e5f4_cda6_c3b0f950bfb2["GenerateTimestamp"]
  273c7454_c6f6_3f2e_89f6_885815c26847 -->|defined in| 2b9767de_2ad4_e5f4_cda6_c3b0f950bfb2
  style 273c7454_c6f6_3f2e_89f6_885815c26847 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-seed/src/services/Generators.ts lines 992–1018

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

		const anchorTimestamp = new Date('2024-05-08');
		const twoYearsInMilliseconds = 2 * 31536000000;

		let date = new Date();
		let milliseconds: number;

		[milliseconds, this.state.rng] = prand.uniformIntDistribution(
			-twoYearsInMilliseconds,
			twoYearsInMilliseconds,
			this.state.rng,
		);
		date = new Date(date.setTime(anchorTimestamp.getTime() + milliseconds));

		if (this.dataType === 'string') {
			return date
				.toISOString()
				.replace('T', ' ')
				.replace(/\.\d{3}Z/, '');
		}

		return date;
	}

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

Analyze Your Own Codebase

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

Try Supermodel Free