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 4bacf9e4_1557_d91d_6e53_3741dd136ea6["init()"] 8c61890c_75a8_857d_b5f1_f4778b502166["GenerateUniquePostcode"] 4bacf9e4_1557_d91d_6e53_3741dd136ea6 -->|defined in| 8c61890c_75a8_857d_b5f1_f4778b502166 style 4bacf9e4_1557_d91d_6e53_3741dd136ea6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
drizzle-seed/src/services/Generators.ts lines 2483–2522
override init({ count, seed }: { count: number; seed: number }) {
const maxUniquePostcodeNumber = Math.pow(10, 5) + Math.pow(10, 9);
if (count > maxUniquePostcodeNumber) {
throw new RangeError(
`count exceeds max number of unique postcodes(${maxUniquePostcodeNumber}).`,
);
}
const rng = prand.xoroshiro128plus(seed);
const templates = [
{
template: '#####',
indicesGen: new GenerateUniqueInt({ minValue: 0, maxValue: Math.pow(10, 5) - 1 }),
placeholdersCount: 5,
count: 0,
maxUniquePostcodeNumber: Math.pow(10, 5),
},
{
template: '#####-####',
indicesGen: new GenerateUniqueInt({ minValue: 0, maxValue: Math.pow(10, 9) - 1 }),
placeholdersCount: 9,
count: 0,
maxUniquePostcodeNumber: Math.pow(10, 9),
},
];
const maxPostcodeLength = Math.max(...templates.map((template) => template.template.length));
if (this.stringLength !== undefined && this.stringLength < maxPostcodeLength) {
throw new Error(
`You can't use postcode generator with a db column length restriction of ${this.stringLength}. Set the maximum string length to at least ${maxPostcodeLength}.`,
);
}
for (const templateObj of templates) {
templateObj.indicesGen.skipCheck = true;
templateObj.indicesGen.init({ count, seed });
}
this.state = { rng, templates };
}
Domain
Subdomains
Defined In
Source
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 2483.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free