GenerateUUID Class — drizzle-orm Architecture
Architecture documentation for the GenerateUUID class in Generators.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 5cbcdb32_076c_3e13_9eda_e9facd30f1c6["GenerateUUID"] e5cee001_0354_7e76_ef0a_06dca71dc8ce["Generators.ts"] 5cbcdb32_076c_3e13_9eda_e9facd30f1c6 -->|defined in| e5cee001_0354_7e76_ef0a_06dca71dc8ce 1c5608fd_5b27_1aaa_6c4b_2c8288f81cbd["init()"] 5cbcdb32_076c_3e13_9eda_e9facd30f1c6 -->|method| 1c5608fd_5b27_1aaa_6c4b_2c8288f81cbd 208c6f9f_5d31_c136_836a_98eea845da47["generate()"] 5cbcdb32_076c_3e13_9eda_e9facd30f1c6 -->|method| 208c6f9f_5d31_c136_836a_98eea845da47
Relationship Graph
Source Code
drizzle-seed/src/services/Generators.ts lines 1513–1557
export class GenerateUUID extends AbstractGenerator<{
arraySize?: number;
}> {
static override readonly entityKind: string = 'GenerateUUID';
public override isUnique = true;
private state: { rng: prand.RandomGenerator } | undefined;
override init({ count, seed }: { count: number; seed: number }) {
super.init({ count, seed });
const rng = prand.xoroshiro128plus(seed);
this.state = { rng };
}
generate() {
if (this.state === undefined) {
throw new Error('state is not defined.');
}
// TODO generate uuid using string generator
const stringChars = '1234567890abcdef';
let idx: number,
currStr: string;
const strLength = 36;
// uuid v4
const uuidTemplate = '########-####-4###-####-############';
currStr = '';
for (let i = 0; i < strLength; i++) {
[idx, this.state.rng] = prand.uniformIntDistribution(
0,
stringChars.length - 1,
this.state.rng,
);
if (uuidTemplate[i] === '#') {
currStr += stringChars[idx];
continue;
}
currStr += uuidTemplate[i];
}
return currStr;
}
}
Domain
Defined In
Source
Frequently Asked Questions
What is the GenerateUUID class?
GenerateUUID is a class in the drizzle-orm codebase, defined in drizzle-seed/src/services/Generators.ts.
Where is GenerateUUID defined?
GenerateUUID is defined in drizzle-seed/src/services/Generators.ts at line 1513.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free