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

smallint.ts — drizzle-orm Source File

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

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

Entity Profile

Dependency Diagram

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

export type MySqlSmallIntBuilderInitial<TName extends string> = MySqlSmallIntBuilder<{
	name: TName;
	dataType: 'number';
	columnType: 'MySqlSmallInt';
	data: number;
	driverParam: number | string;
	enumValues: undefined;
}>;

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

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

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

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

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

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

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

Domain

Subdomains

Functions

Dependencies

Frequently Asked Questions

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