Home / Class/ SeedPromise Class — drizzle-orm Architecture

SeedPromise Class — drizzle-orm Architecture

Architecture documentation for the SeedPromise class in index.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  e53626ab_1a6a_57c1_40b3_bbcb9faf43aa["SeedPromise"]
  0fabdd81_61c9_bb7c_7ddf_dde7a6071abc["index.ts"]
  e53626ab_1a6a_57c1_40b3_bbcb9faf43aa -->|defined in| 0fabdd81_61c9_bb7c_7ddf_dde7a6071abc
  b3bd787d_4fbb_a8c5_ab99_21be32389717["constructor()"]
  e53626ab_1a6a_57c1_40b3_bbcb9faf43aa -->|method| b3bd787d_4fbb_a8c5_ab99_21be32389717
  aeeb2367_a282_b6b2_4971_15a31b04f9fe["then()"]
  e53626ab_1a6a_57c1_40b3_bbcb9faf43aa -->|method| aeeb2367_a282_b6b2_4971_15a31b04f9fe
  65fd1edb_94c5_195f_d259_d8bdc93936d9["catch()"]
  e53626ab_1a6a_57c1_40b3_bbcb9faf43aa -->|method| 65fd1edb_94c5_195f_d259_d8bdc93936d9
  3cb3a528_182d_8371_2d5b_e0bd89f4a501["finally()"]
  e53626ab_1a6a_57c1_40b3_bbcb9faf43aa -->|method| 3cb3a528_182d_8371_2d5b_e0bd89f4a501
  0922125a_3416_ba42_60a1_e3254e166402["refine()"]
  e53626ab_1a6a_57c1_40b3_bbcb9faf43aa -->|method| 0922125a_3416_ba42_60a1_e3254e166402

Relationship Graph

Source Code

drizzle-seed/src/index.ts lines 137–206

class SeedPromise<
	DB extends
		| PgDatabase<any, any>
		| MySqlDatabase<any, any>
		| BaseSQLiteDatabase<any, any>,
	SCHEMA extends {
		[key: string]: PgTable | PgSchema | MySqlTable | MySqlSchema | SQLiteTable | Relations;
	},
	VERSION extends string | undefined,
> implements Promise<void> {
	static readonly entityKind: string = 'SeedPromise';

	[Symbol.toStringTag] = 'SeedPromise';

	constructor(
		private db: DB,
		private schema: SCHEMA,
		private options?: { count?: number; seed?: number; version?: VERSION },
	) {}

	then<TResult1 = void, TResult2 = never>(
		onfulfilled?:
			| ((value: void) => TResult1 | PromiseLike<TResult1>)
			| null
			| undefined,
		onrejected?:
			| ((reason: any) => TResult2 | PromiseLike<TResult2>)
			| null
			| undefined,
	): Promise<TResult1 | TResult2> {
		return seedFunc(this.db, this.schema, this.options).then(
			onfulfilled,
			onrejected,
		);
	}

	catch<TResult = never>(
		onrejected?:
			| ((reason: any) => TResult | PromiseLike<TResult>)
			| null
			| undefined,
	): Promise<void | TResult> {
		return this.then(undefined, onrejected);
	}

	finally(onfinally?: (() => void) | null | undefined): Promise<void> {
		return this.then(
			(value) => {
				onfinally?.();
				return value;
			},
			(reason) => {
				onfinally?.();
				throw reason;
			},
		);
	}

	async refine(
		callback: (
			funcs: FunctionsVersioning<VERSION>,
		) => InferCallbackType<DB, SCHEMA>,
	): Promise<void> {
		const refinements = this.options?.version === undefined || this.options.version === '2'
			? callback(generatorsFuncsV2 as FunctionsVersioning<VERSION>) as RefinementsType
			: callback(generatorsFuncs as FunctionsVersioning<VERSION>) as RefinementsType;

		await seedFunc(this.db, this.schema, this.options, refinements);
	}
}

Domain

Frequently Asked Questions

What is the SeedPromise class?
SeedPromise is a class in the drizzle-orm codebase, defined in drizzle-seed/src/index.ts.
Where is SeedPromise defined?
SeedPromise is defined in drizzle-seed/src/index.ts at line 137.

Analyze Your Own Codebase

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

Try Supermodel Free