Home / File/ text.ts — drizzle-orm Source File

text.ts — drizzle-orm Source File

Architecture documentation for text.ts, a typescript file in the drizzle-orm codebase. 7 imports, 1 dependents.

File typescript DrizzleORM SQLDialects 7 imports 1 dependents 4 functions 2 classes

Entity Profile

Dependency Diagram

graph LR
  21ea5431_beac_3363_5280_45ca68ef3fdb["text.ts"]
  83c65ad5_22a0_d33f_47b8_c2ed1c8d8bbb["common.ts"]
  21ea5431_beac_3363_5280_45ca68ef3fdb --> 83c65ad5_22a0_d33f_47b8_c2ed1c8d8bbb
  8da43de9_1be1_48fb_1db1_a6bc59f5b306["MySqlColumn"]
  21ea5431_beac_3363_5280_45ca68ef3fdb --> 8da43de9_1be1_48fb_1db1_a6bc59f5b306
  2dc784c6_95e9_4e28_ec81_7caf4acbd426["column-builder.ts"]
  21ea5431_beac_3363_5280_45ca68ef3fdb --> 2dc784c6_95e9_4e28_ec81_7caf4acbd426
  05f0a280_d0c9_693a_a4bf_83cc671012d2["column.ts"]
  21ea5431_beac_3363_5280_45ca68ef3fdb --> 05f0a280_d0c9_693a_a4bf_83cc671012d2
  27705a9d_afe9_57dd_8c97_e52d8a67d426["entity.ts"]
  21ea5431_beac_3363_5280_45ca68ef3fdb --> 27705a9d_afe9_57dd_8c97_e52d8a67d426
  70e1783e_f575_ccd4_36bd_5f0978c2172c["table.ts"]
  21ea5431_beac_3363_5280_45ca68ef3fdb --> 70e1783e_f575_ccd4_36bd_5f0978c2172c
  ecce3253_1e75_a87f_27b3_ca87e81a3024["utils.ts"]
  21ea5431_beac_3363_5280_45ca68ef3fdb --> ecce3253_1e75_a87f_27b3_ca87e81a3024
  6dd15b44_b15c_62ef_81b2_e72b28299be9["all.ts"]
  6dd15b44_b15c_62ef_81b2_e72b28299be9 --> 21ea5431_beac_3363_5280_45ca68ef3fdb
  style 21ea5431_beac_3363_5280_45ca68ef3fdb fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import type { ColumnBuilderBaseConfig, ColumnBuilderRuntimeConfig, MakeColumnConfig } from '~/column-builder.ts';
import type { ColumnBaseConfig } from '~/column.ts';
import { entityKind } from '~/entity.ts';
import type { AnyMySqlTable } from '~/mysql-core/table.ts';
import { getColumnNameAndConfig, type Writable } from '~/utils.ts';
import { MySqlColumn, MySqlColumnBuilder } from './common.ts';

export type MySqlTextColumnType = 'tinytext' | 'text' | 'mediumtext' | 'longtext';

export type MySqlTextBuilderInitial<TName extends string, TEnum extends [string, ...string[]]> = MySqlTextBuilder<{
	name: TName;
	dataType: 'string';
	columnType: 'MySqlText';
	data: TEnum[number];
	driverParam: string;
	enumValues: TEnum;
}>;

export class MySqlTextBuilder<T extends ColumnBuilderBaseConfig<'string', 'MySqlText'>> extends MySqlColumnBuilder<
	T,
	{ textType: MySqlTextColumnType; enumValues: T['enumValues'] }
> {
	static override readonly [entityKind]: string = 'MySqlTextBuilder';

	constructor(name: T['name'], textType: MySqlTextColumnType, config: MySqlTextConfig<T['enumValues']>) {
		super(name, 'string', 'MySqlText');
		this.config.textType = textType;
		this.config.enumValues = config.enum;
	}

	/** @internal */
	override build<TTableName extends string>(
		table: AnyMySqlTable<{ name: TTableName }>,
	): MySqlText<MakeColumnConfig<T, TTableName>> {
		return new MySqlText<MakeColumnConfig<T, TTableName>>(table, this.config as ColumnBuilderRuntimeConfig<any, any>);
	}
}

export class MySqlText<T extends ColumnBaseConfig<'string', 'MySqlText'>>
	extends MySqlColumn<T, { textType: MySqlTextColumnType; enumValues: T['enumValues'] }>
{
	static override readonly [entityKind]: string = 'MySqlText';

	readonly textType: MySqlTextColumnType = this.config.textType;

	override readonly enumValues = this.config.enumValues;

	getSQLType(): string {
		return this.textType;
	}
}

export interface MySqlTextConfig<
	TEnum extends readonly string[] | string[] | undefined = readonly string[] | string[] | undefined,
> {
	enum?: TEnum;
}

export function text(): MySqlTextBuilderInitial<'', [string, ...string[]]>;
export function text<U extends string, T extends Readonly<[U, ...U[]]>>(
	config?: MySqlTextConfig<T | Writable<T>>,
): MySqlTextBuilderInitial<'', Writable<T>>;
export function text<TName extends string, U extends string, T extends Readonly<[U, ...U[]]>>(
	name: TName,
	config?: MySqlTextConfig<T | Writable<T>>,
): MySqlTextBuilderInitial<TName, Writable<T>>;
export function text(a?: string | MySqlTextConfig, b: MySqlTextConfig = {}): any {
	const { name, config } = getColumnNameAndConfig<MySqlTextConfig>(a, b);
	return new MySqlTextBuilder(name, 'text', config as any);
}

export function tinytext(): MySqlTextBuilderInitial<'', [string, ...string[]]>;
export function tinytext<U extends string, T extends Readonly<[U, ...U[]]>>(
	config?: MySqlTextConfig<T | Writable<T>>,
): MySqlTextBuilderInitial<'', Writable<T>>;
export function tinytext<TName extends string, U extends string, T extends Readonly<[U, ...U[]]>>(
	name: TName,
	config?: MySqlTextConfig<T | Writable<T>>,
): MySqlTextBuilderInitial<TName, Writable<T>>;
export function tinytext(a?: string | MySqlTextConfig, b: MySqlTextConfig = {}): any {
	const { name, config } = getColumnNameAndConfig<MySqlTextConfig>(a, b);
	return new MySqlTextBuilder(name, 'tinytext', config as any);
}

export function mediumtext(): MySqlTextBuilderInitial<'', [string, ...string[]]>;
export function mediumtext<U extends string, T extends Readonly<[U, ...U[]]>>(
	config?: MySqlTextConfig<T | Writable<T>>,
): MySqlTextBuilderInitial<'', Writable<T>>;
export function mediumtext<TName extends string, U extends string, T extends Readonly<[U, ...U[]]>>(
	name: TName,
	config?: MySqlTextConfig<T | Writable<T>>,
): MySqlTextBuilderInitial<TName, Writable<T>>;
export function mediumtext(a?: string | MySqlTextConfig, b: MySqlTextConfig = {}): any {
	const { name, config } = getColumnNameAndConfig<MySqlTextConfig>(a, b);
	return new MySqlTextBuilder(name, 'mediumtext', config as any);
}

export function longtext(): MySqlTextBuilderInitial<'', [string, ...string[]]>;
export function longtext<U extends string, T extends Readonly<[U, ...U[]]>>(
	config?: MySqlTextConfig<T | Writable<T>>,
): MySqlTextBuilderInitial<'', Writable<T>>;
export function longtext<TName extends string, U extends string, T extends Readonly<[U, ...U[]]>>(
	name: TName,
	config?: MySqlTextConfig<T | Writable<T>>,
): MySqlTextBuilderInitial<TName, Writable<T>>;
export function longtext(a?: string | MySqlTextConfig, b: MySqlTextConfig = {}): any {
	const { name, config } = getColumnNameAndConfig<MySqlTextConfig>(a, b);
	return new MySqlTextBuilder(name, 'longtext', config as any);
}

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does text.ts do?
text.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleORM domain, SQLDialects subdomain.
What functions are defined in text.ts?
text.ts defines 4 function(s): longtext, mediumtext, text, tinytext.
What does text.ts depend on?
text.ts imports 7 module(s): MySqlColumn, column-builder.ts, column.ts, common.ts, entity.ts, table.ts, utils.ts.
What files import text.ts?
text.ts is imported by 1 file(s): all.ts.
Where is text.ts in the architecture?
text.ts is located at drizzle-orm/src/mysql-core/columns/text.ts (domain: DrizzleORM, subdomain: SQLDialects, directory: drizzle-orm/src/mysql-core/columns).

Analyze Your Own Codebase

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

Try Supermodel Free