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
  07fecfcd_d3cc_41ab_9a1f_d57432f45a01["init()"]
  2d763d92_faa5_50ae_1f76_896734c85168["GenerateEmail"]
  07fecfcd_d3cc_41ab_9a1f_d57432f45a01 -->|defined in| 2d763d92_faa5_50ae_1f76_896734c85168
  style 07fecfcd_d3cc_41ab_9a1f_d57432f45a01 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-seed/src/services/Generators.ts lines 1835–1864

	override init({ count, seed }: { count: number; seed: number }) {
		super.init({ count, seed });

		const domainsArray = emailDomains;
		const adjectivesArray = adjectives;
		const namesArray = firstNames;

		const maxUniqueEmailsNumber = adjectivesArray.length * namesArray.length * domainsArray.length;
		if (count > maxUniqueEmailsNumber) {
			throw new RangeError(
				`count exceeds max number of unique emails(${maxUniqueEmailsNumber}).`,
			);
		}

		const maxEmailLength = maxAdjectiveLength + maxFirstNameLength + maxEmailDomainLength + 2;
		if (this.stringLength !== undefined && this.stringLength < maxEmailLength) {
			throw new Error(
				`You can't use email generator with a db column length restriction of ${this.stringLength}. Set the maximum string length to at least ${maxEmailLength}.`,
			);
		}

		const arraysToGenerateFrom = [adjectivesArray, namesArray, domainsArray];
		const genIndicesObj = new GenerateUniqueInt({
			minValue: 0,
			maxValue: maxUniqueEmailsNumber - 1,
		});
		genIndicesObj.init({ count, seed });

		this.state = { genIndicesObj, arraysToGenerateFrom };
	}

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

Analyze Your Own Codebase

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

Try Supermodel Free