GenerateUniqueNumber Class — drizzle-orm Architecture
Architecture documentation for the GenerateUniqueNumber class in Generators.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 2b91fec6_1c41_b27b_8c9b_f88d462b911f["GenerateUniqueNumber"] e5cee001_0354_7e76_ef0a_06dca71dc8ce["Generators.ts"] 2b91fec6_1c41_b27b_8c9b_f88d462b911f -->|defined in| e5cee001_0354_7e76_ef0a_06dca71dc8ce f506f47a_6bce_0375_2e5c_1a996d5792e8["init()"] 2b91fec6_1c41_b27b_8c9b_f88d462b911f -->|method| f506f47a_6bce_0375_2e5c_1a996d5792e8 81b64db6_b206_b982_edd3_711164648868["generate()"] 2b91fec6_1c41_b27b_8c9b_f88d462b911f -->|method| 81b64db6_b206_b982_edd3_711164648868
Relationship Graph
Source Code
drizzle-seed/src/services/Generators.ts lines 520–572
export class GenerateUniqueNumber extends AbstractGenerator<
{
minValue?: number;
maxValue?: number;
precision?: number;
isUnique?: boolean;
}
> {
static override readonly entityKind: string = 'GenerateUniqueNumber';
private state: {
genUniqueIntObj: GenerateUniqueInt;
minValue: number;
maxValue: number;
precision: number;
} | undefined;
public override isUnique = true;
override init({ count, seed }: { count: number; seed: number }) {
let { minValue, maxValue, precision } = this.params;
if (precision === undefined) {
precision = 100;
}
if (maxValue === undefined) {
maxValue = count * precision;
} else {
maxValue *= precision;
}
if (minValue === undefined) {
minValue = -maxValue;
} else {
minValue *= precision;
}
const genUniqueIntObj = new GenerateUniqueInt({ minValue, maxValue });
genUniqueIntObj.init({ count, seed });
this.state = { genUniqueIntObj, minValue, maxValue, precision };
}
generate() {
if (this.state === undefined) {
throw new Error('state is not defined.');
}
const value = this.state.genUniqueIntObj.generate() as number / this.state.precision;
return value;
}
}
Domain
Defined In
Source
Frequently Asked Questions
What is the GenerateUniqueNumber class?
GenerateUniqueNumber is a class in the drizzle-orm codebase, defined in drizzle-seed/src/services/Generators.ts.
Where is GenerateUniqueNumber defined?
GenerateUniqueNumber is defined in drizzle-seed/src/services/Generators.ts at line 520.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free