GenerateSelfRelationsValuesFromArray Class — drizzle-orm Architecture
Architecture documentation for the GenerateSelfRelationsValuesFromArray class in Generators.ts from the drizzle-orm codebase.
Entity Profile
Dependency Diagram
graph TD 0637aa7d_8c2a_0a6b_85ca_fea89c990a65["GenerateSelfRelationsValuesFromArray"] ad368962_b0c4_ad39_7eb4_89a4a018419d["Generators.ts"] 0637aa7d_8c2a_0a6b_85ca_fea89c990a65 -->|defined in| ad368962_b0c4_ad39_7eb4_89a4a018419d 65c77671_98e0_e3ff_3fc7_71a4985cc24f["init()"] 0637aa7d_8c2a_0a6b_85ca_fea89c990a65 -->|method| 65c77671_98e0_e3ff_3fc7_71a4985cc24f e430fbb5_40c3_115b_754c_9608e4cdded5["generate()"] 0637aa7d_8c2a_0a6b_85ca_fea89c990a65 -->|method| e430fbb5_40c3_115b_754c_9608e4cdded5
Relationship Graph
Source Code
drizzle-seed/src/services/Generators.ts lines 406–442
export class GenerateSelfRelationsValuesFromArray extends AbstractGenerator<{ values: (number | string | boolean)[] }> {
static override readonly entityKind: string = 'GenerateSelfRelationsValuesFromArray';
private state: {
rng: prand.RandomGenerator;
firstValuesCount: number;
firstValues: (string | number | boolean)[];
} | undefined;
override init({ count, seed }: { count: number; seed: number }) {
let rng = prand.xoroshiro128plus(seed);
// generate 15-40 % values with the same value as reference column
let percent = 30;
[percent, rng] = prand.uniformIntDistribution(20, 40, rng);
const firstValuesCount = Math.floor((percent / 100) * count), firstValues: (string | number | boolean)[] = [];
this.state = { rng, firstValuesCount, firstValues };
}
generate({ i }: { i: number }) {
if (this.state === undefined) {
throw new Error('state is not defined.');
}
const { values } = this.params;
let idx: number;
if (i < this.state.firstValuesCount) {
this.state.firstValues.push(values[i]!);
return values[i];
} else {
[idx, this.state.rng] = prand.uniformIntDistribution(0, this.state.firstValues.length - 1, this.state.rng);
return this.state.firstValues[idx];
}
}
}
Domain
Defined In
Source
Frequently Asked Questions
What is the GenerateSelfRelationsValuesFromArray class?
GenerateSelfRelationsValuesFromArray is a class in the drizzle-orm codebase, defined in drizzle-seed/src/services/Generators.ts.
Where is GenerateSelfRelationsValuesFromArray defined?
GenerateSelfRelationsValuesFromArray is defined in drizzle-seed/src/services/Generators.ts at line 406.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free