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
  4582ade4_7ca4_4a2f_0f85_b1b5f69b8e12["generate()"]
  e2a00ddd_39cc_f1ee_ae9d_eba53324177d["GenerateDatetime"]
  4582ade4_7ca4_4a2f_0f85_b1b5f69b8e12 -->|defined in| e2a00ddd_39cc_f1ee_ae9d_eba53324177d
  style 4582ade4_7ca4_4a2f_0f85_b1b5f69b8e12 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-seed/src/services/Generators.ts lines 1036–1062

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

		const anchorDate = 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(anchorDate.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 1036.

Analyze Your Own Codebase

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

Try Supermodel Free