Home / Function/ customType() — drizzle-orm Function Reference

customType() — drizzle-orm Function Reference

Architecture documentation for the customType() function in custom.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  c8260192_cad9_573b_ce82_35e32e60fe11["customType()"]
  2d665331_c10f_e80b_925f_d2148b29ca86["custom.ts"]
  c8260192_cad9_573b_ce82_35e32e60fe11 -->|defined in| 2d665331_c10f_e80b_925f_d2148b29ca86
  style c8260192_cad9_573b_ce82_35e32e60fe11 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

drizzle-orm/src/pg-core/columns/custom.ts lines 203–232

export function customType<T extends CustomTypeValues = CustomTypeValues>(
	customTypeParams: CustomTypeParams<T>,
): Equal<T['configRequired'], true> extends true ? {
		<TConfig extends Record<string, any> & T['config']>(
			fieldConfig: TConfig,
		): PgCustomColumnBuilder<ConvertCustomConfig<'', T>>;
		<TName extends string>(
			dbName: TName,
			fieldConfig: T['config'],
		): PgCustomColumnBuilder<ConvertCustomConfig<TName, T>>;
	}
	: {
		(): PgCustomColumnBuilder<ConvertCustomConfig<'', T>>;
		<TConfig extends Record<string, any> & T['config']>(
			fieldConfig?: TConfig,
		): PgCustomColumnBuilder<ConvertCustomConfig<'', T>>;
		<TName extends string>(
			dbName: TName,
			fieldConfig?: T['config'],
		): PgCustomColumnBuilder<ConvertCustomConfig<TName, T>>;
	}
{
	return <TName extends string>(
		a?: TName | T['config'],
		b?: T['config'],
	): PgCustomColumnBuilder<ConvertCustomConfig<TName, T>> => {
		const { name, config } = getColumnNameAndConfig<T['config']>(a, b);
		return new PgCustomColumnBuilder(name as ConvertCustomConfig<TName, T>['name'], config, customTypeParams);
	};
}

Domain

Subdomains

Frequently Asked Questions

What does customType() do?
customType() is a function in the drizzle-orm codebase, defined in drizzle-orm/src/pg-core/columns/custom.ts.
Where is customType() defined?
customType() is defined in drizzle-orm/src/pg-core/columns/custom.ts at line 203.

Analyze Your Own Codebase

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

Try Supermodel Free