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

init() — drizzle-orm Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  1b63fb81_68fc_f27d_650e_b0c1d2836d88["init()"]
  d04a1bec_874f_b44b_134d_a8d1f0772da3["GenerateDate"]
  1b63fb81_68fc_f27d_650e_b0c1d2836d88 -->|defined in| d04a1bec_874f_b44b_134d_a8d1f0772da3
  style 1b63fb81_68fc_f27d_650e_b0c1d2836d88 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-seed/src/services/Generators.ts lines 855–886

	override init({ count, seed }: { count: number; seed: number }) {
		super.init({ count, seed });
		const rng = prand.xoroshiro128plus(seed);

		let { minDate, maxDate } = this.params;

		const anchorDate = new Date('2024-05-08');
		const deltaMilliseconds = 4 * 31536000000;

		if (typeof minDate === 'string') {
			minDate = new Date(minDate);
		}

		if (typeof maxDate === 'string') {
			maxDate = new Date(maxDate);
		}

		if (minDate === undefined) {
			if (maxDate === undefined) {
				minDate = new Date(anchorDate.getTime() - deltaMilliseconds);
				maxDate = new Date(anchorDate.getTime() + deltaMilliseconds);
			} else {
				minDate = new Date(maxDate.getTime() - (2 * deltaMilliseconds));
			}
		}

		if (maxDate === undefined) {
			maxDate = new Date(minDate.getTime() + (2 * deltaMilliseconds));
		}

		this.state = { rng, minDate, maxDate };
	}

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free