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. 8 imports, 3 dependents.

File typescript DrizzleORM DatabaseDrivers 8 imports 3 dependents 1 functions 4 classes

Entity Profile

Dependency Diagram

graph LR
  a7bcec86_fec9_446d_0dc2_721126dd50c7["timestamp.ts"]
  f4f42b4c_8610_03dd_fe01_232098668127["common.ts"]
  a7bcec86_fec9_446d_0dc2_721126dd50c7 --> f4f42b4c_8610_03dd_fe01_232098668127
  099d7c6d_2fc4_7b20_40e3_1b8af4138fe6["PgColumn"]
  a7bcec86_fec9_446d_0dc2_721126dd50c7 --> 099d7c6d_2fc4_7b20_40e3_1b8af4138fe6
  40f2fd93_0821_09d6_99ff_d1f9b2b69641["date.common.ts"]
  a7bcec86_fec9_446d_0dc2_721126dd50c7 --> 40f2fd93_0821_09d6_99ff_d1f9b2b69641
  2dc784c6_95e9_4e28_ec81_7caf4acbd426["column-builder.ts"]
  a7bcec86_fec9_446d_0dc2_721126dd50c7 --> 2dc784c6_95e9_4e28_ec81_7caf4acbd426
  05f0a280_d0c9_693a_a4bf_83cc671012d2["column.ts"]
  a7bcec86_fec9_446d_0dc2_721126dd50c7 --> 05f0a280_d0c9_693a_a4bf_83cc671012d2
  27705a9d_afe9_57dd_8c97_e52d8a67d426["entity.ts"]
  a7bcec86_fec9_446d_0dc2_721126dd50c7 --> 27705a9d_afe9_57dd_8c97_e52d8a67d426
  17418917_ff81_c4e5_90f4_f37d557e5d51["table.ts"]
  a7bcec86_fec9_446d_0dc2_721126dd50c7 --> 17418917_ff81_c4e5_90f4_f37d557e5d51
  ecce3253_1e75_a87f_27b3_ca87e81a3024["utils.ts"]
  a7bcec86_fec9_446d_0dc2_721126dd50c7 --> ecce3253_1e75_a87f_27b3_ca87e81a3024
  b38cf654_48d6_41dc_6c0f_203697984d98["all.ts"]
  b38cf654_48d6_41dc_6c0f_203697984d98 --> a7bcec86_fec9_446d_0dc2_721126dd50c7
  61d79bcb_2d33_f225_b684_5a569e544c53["interval.ts"]
  61d79bcb_2d33_f225_b684_5a569e544c53 --> a7bcec86_fec9_446d_0dc2_721126dd50c7
  7102357c_0ef2_b03e_a1a8_871e6fea8eac["time.ts"]
  7102357c_0ef2_b03e_a1a8_871e6fea8eac --> a7bcec86_fec9_446d_0dc2_721126dd50c7
  style a7bcec86_fec9_446d_0dc2_721126dd50c7 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 { AnyPgTable } from '~/pg-core/table.ts';
import { type Equal, getColumnNameAndConfig } from '~/utils.ts';
import { PgColumn } from './common.ts';
import { PgDateColumnBaseBuilder } from './date.common.ts';

export type PgTimestampBuilderInitial<TName extends string> = PgTimestampBuilder<{
	name: TName;
	dataType: 'date';
	columnType: 'PgTimestamp';
	data: Date;
	driverParam: string;
	enumValues: undefined;
}>;

export class PgTimestampBuilder<T extends ColumnBuilderBaseConfig<'date', 'PgTimestamp'>>
	extends PgDateColumnBaseBuilder<
		T,
		{ withTimezone: boolean; precision: number | undefined }
	>
{
	static override readonly [entityKind]: string = 'PgTimestampBuilder';

	constructor(
		name: T['name'],
		withTimezone: boolean,
		precision: number | undefined,
	) {
		super(name, 'date', 'PgTimestamp');
		this.config.withTimezone = withTimezone;
		this.config.precision = precision;
	}

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

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

	readonly withTimezone: boolean;
	readonly precision: number | undefined;

	constructor(table: AnyPgTable<{ name: T['tableName'] }>, config: PgTimestampBuilder<T>['config']) {
		super(table, config);
		this.withTimezone = config.withTimezone;
		this.precision = config.precision;
	}

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

// ... (104 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, DatabaseDrivers subdomain.
What functions are defined in timestamp.ts?
timestamp.ts defines 1 function(s): timestamp.
What does timestamp.ts depend on?
timestamp.ts imports 8 module(s): PgColumn, column-builder.ts, column.ts, common.ts, date.common.ts, entity.ts, table.ts, utils.ts.
What files import timestamp.ts?
timestamp.ts is imported by 3 file(s): all.ts, interval.ts, time.ts.
Where is timestamp.ts in the architecture?
timestamp.ts is located at drizzle-orm/src/pg-core/columns/timestamp.ts (domain: DrizzleORM, subdomain: DatabaseDrivers, directory: drizzle-orm/src/pg-core/columns).

Analyze Your Own Codebase

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

Try Supermodel Free