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

timestamp.ts — drizzle-orm Source File

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

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

Entity Profile

Dependency Diagram

graph LR
  3f4b2513_5741_1f8c_8c92_e76673d698a6["timestamp.ts"]
  ad03c9b1_961e_2b53_cf32_4012da6d88c5["date.common.ts"]
  3f4b2513_5741_1f8c_8c92_e76673d698a6 --> ad03c9b1_961e_2b53_cf32_4012da6d88c5
  2dc784c6_95e9_4e28_ec81_7caf4acbd426["column-builder.ts"]
  3f4b2513_5741_1f8c_8c92_e76673d698a6 --> 2dc784c6_95e9_4e28_ec81_7caf4acbd426
  05f0a280_d0c9_693a_a4bf_83cc671012d2["column.ts"]
  3f4b2513_5741_1f8c_8c92_e76673d698a6 --> 05f0a280_d0c9_693a_a4bf_83cc671012d2
  27705a9d_afe9_57dd_8c97_e52d8a67d426["entity.ts"]
  3f4b2513_5741_1f8c_8c92_e76673d698a6 --> 27705a9d_afe9_57dd_8c97_e52d8a67d426
  70e1783e_f575_ccd4_36bd_5f0978c2172c["table.ts"]
  3f4b2513_5741_1f8c_8c92_e76673d698a6 --> 70e1783e_f575_ccd4_36bd_5f0978c2172c
  ecce3253_1e75_a87f_27b3_ca87e81a3024["utils.ts"]
  3f4b2513_5741_1f8c_8c92_e76673d698a6 --> ecce3253_1e75_a87f_27b3_ca87e81a3024
  6dd15b44_b15c_62ef_81b2_e72b28299be9["all.ts"]
  6dd15b44_b15c_62ef_81b2_e72b28299be9 --> 3f4b2513_5741_1f8c_8c92_e76673d698a6
  style 3f4b2513_5741_1f8c_8c92_e76673d698a6 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 { type Equal, getColumnNameAndConfig } from '~/utils.ts';
import { MySqlDateBaseColumn, MySqlDateColumnBaseBuilder } from './date.common.ts';

export type MySqlTimestampBuilderInitial<TName extends string> = MySqlTimestampBuilder<{
	name: TName;
	dataType: 'date';
	columnType: 'MySqlTimestamp';
	data: Date;
	driverParam: string | number;
	enumValues: undefined;
}>;

export class MySqlTimestampBuilder<T extends ColumnBuilderBaseConfig<'date', 'MySqlTimestamp'>>
	extends MySqlDateColumnBaseBuilder<T, MySqlTimestampConfig>
{
	static override readonly [entityKind]: string = 'MySqlTimestampBuilder';

	constructor(name: T['name'], config: MySqlTimestampConfig | undefined) {
		super(name, 'date', 'MySqlTimestamp');
		this.config.fsp = config?.fsp;
	}

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

export class MySqlTimestamp<T extends ColumnBaseConfig<'date', 'MySqlTimestamp'>>
	extends MySqlDateBaseColumn<T, MySqlTimestampConfig>
{
	static override readonly [entityKind]: string = 'MySqlTimestamp';

	readonly fsp: number | undefined = this.config.fsp;

	getSQLType(): string {
		const precision = this.fsp === undefined ? '' : `(${this.fsp})`;
		return `timestamp${precision}`;
	}

	override mapFromDriverValue(value: string): Date {
		return new Date(value + '+0000');
	}

	override mapToDriverValue(value: Date): string {
		return value.toISOString().slice(0, -1).replace('T', ' ');
	}
}

export type MySqlTimestampStringBuilderInitial<TName extends string> = MySqlTimestampStringBuilder<{
	name: TName;
// ... (66 more lines)

Domain

Subdomains

Functions

Dependencies

Frequently Asked Questions

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