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

int.ts — drizzle-orm Source File

Architecture documentation for int.ts, a typescript file in the drizzle-orm codebase. 6 imports, 4 dependents.

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

Entity Profile

Dependency Diagram

graph LR
  d9cbb4b8_099f_202c_f966_e6dfe9688e35["int.ts"]
  83c65ad5_22a0_d33f_47b8_c2ed1c8d8bbb["common.ts"]
  d9cbb4b8_099f_202c_f966_e6dfe9688e35 --> 83c65ad5_22a0_d33f_47b8_c2ed1c8d8bbb
  2dc784c6_95e9_4e28_ec81_7caf4acbd426["column-builder.ts"]
  d9cbb4b8_099f_202c_f966_e6dfe9688e35 --> 2dc784c6_95e9_4e28_ec81_7caf4acbd426
  05f0a280_d0c9_693a_a4bf_83cc671012d2["column.ts"]
  d9cbb4b8_099f_202c_f966_e6dfe9688e35 --> 05f0a280_d0c9_693a_a4bf_83cc671012d2
  27705a9d_afe9_57dd_8c97_e52d8a67d426["entity.ts"]
  d9cbb4b8_099f_202c_f966_e6dfe9688e35 --> 27705a9d_afe9_57dd_8c97_e52d8a67d426
  70e1783e_f575_ccd4_36bd_5f0978c2172c["table.ts"]
  d9cbb4b8_099f_202c_f966_e6dfe9688e35 --> 70e1783e_f575_ccd4_36bd_5f0978c2172c
  ecce3253_1e75_a87f_27b3_ca87e81a3024["utils.ts"]
  d9cbb4b8_099f_202c_f966_e6dfe9688e35 --> ecce3253_1e75_a87f_27b3_ca87e81a3024
  6dd15b44_b15c_62ef_81b2_e72b28299be9["all.ts"]
  6dd15b44_b15c_62ef_81b2_e72b28299be9 --> d9cbb4b8_099f_202c_f966_e6dfe9688e35
  91820bea_a9fe_23cc_53d0_e524655fd2a2["mediumint.ts"]
  91820bea_a9fe_23cc_53d0_e524655fd2a2 --> d9cbb4b8_099f_202c_f966_e6dfe9688e35
  934915b8_8c53_b26e_e688_2445914177f2["smallint.ts"]
  934915b8_8c53_b26e_e688_2445914177f2 --> d9cbb4b8_099f_202c_f966_e6dfe9688e35
  e2933329_fbd5_9471_e054_a461e80d4c18["tinyint.ts"]
  e2933329_fbd5_9471_e054_a461e80d4c18 --> d9cbb4b8_099f_202c_f966_e6dfe9688e35
  style d9cbb4b8_099f_202c_f966_e6dfe9688e35 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 } from '~/utils.ts';
import { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common.ts';

export type MySqlIntBuilderInitial<TName extends string> = MySqlIntBuilder<{
	name: TName;
	dataType: 'number';
	columnType: 'MySqlInt';
	data: number;
	driverParam: number | string;
	enumValues: undefined;
}>;

export class MySqlIntBuilder<T extends ColumnBuilderBaseConfig<'number', 'MySqlInt'>>
	extends MySqlColumnBuilderWithAutoIncrement<T, MySqlIntConfig>
{
	static override readonly [entityKind]: string = 'MySqlIntBuilder';

	constructor(name: T['name'], config?: MySqlIntConfig) {
		super(name, 'number', 'MySqlInt');
		this.config.unsigned = config ? config.unsigned : false;
	}

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

export class MySqlInt<T extends ColumnBaseConfig<'number', 'MySqlInt'>>
	extends MySqlColumnWithAutoIncrement<T, MySqlIntConfig>
{
	static override readonly [entityKind]: string = 'MySqlInt';

	getSQLType(): string {
		return `int${this.config.unsigned ? ' unsigned' : ''}`;
	}

	override mapFromDriverValue(value: number | string): number {
		if (typeof value === 'string') {
			return Number(value);
		}
		return value;
	}
}

export interface MySqlIntConfig {
	unsigned?: boolean;
}

export function int(): MySqlIntBuilderInitial<''>;
export function int(
	config?: MySqlIntConfig,
): MySqlIntBuilderInitial<''>;
export function int<TName extends string>(
	name: TName,
	config?: MySqlIntConfig,
): MySqlIntBuilderInitial<TName>;
export function int(a?: string | MySqlIntConfig, b?: MySqlIntConfig) {
	const { name, config } = getColumnNameAndConfig<MySqlIntConfig>(a, b);
	return new MySqlIntBuilder(name, config);
}

Domain

Subdomains

Functions

Dependencies

  • column-builder.ts
  • column.ts
  • common.ts
  • entity.ts
  • table.ts
  • utils.ts

Frequently Asked Questions

What does int.ts do?
int.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 int.ts?
int.ts defines 1 function(s): int.
What does int.ts depend on?
int.ts imports 6 module(s): column-builder.ts, column.ts, common.ts, entity.ts, table.ts, utils.ts.
What files import int.ts?
int.ts is imported by 4 file(s): all.ts, mediumint.ts, smallint.ts, tinyint.ts.
Where is int.ts in the architecture?
int.ts is located at drizzle-orm/src/mysql-core/columns/int.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