timestamp.d.cts 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import type { ColumnBuilderBaseConfig } from "../../column-builder.cjs";
  2. import type { ColumnBaseConfig } from "../../column.cjs";
  3. import { entityKind } from "../../entity.cjs";
  4. import type { AnyPgTable } from "../table.cjs";
  5. import { type Equal } from "../../utils.cjs";
  6. import { PgColumn } from "./common.cjs";
  7. import { PgDateColumnBaseBuilder } from "./date.common.cjs";
  8. export type PgTimestampBuilderInitial<TName extends string> = PgTimestampBuilder<{
  9. name: TName;
  10. dataType: 'date';
  11. columnType: 'PgTimestamp';
  12. data: Date;
  13. driverParam: string;
  14. enumValues: undefined;
  15. }>;
  16. export declare class PgTimestampBuilder<T extends ColumnBuilderBaseConfig<'date', 'PgTimestamp'>> extends PgDateColumnBaseBuilder<T, {
  17. withTimezone: boolean;
  18. precision: number | undefined;
  19. }> {
  20. static readonly [entityKind]: string;
  21. constructor(name: T['name'], withTimezone: boolean, precision: number | undefined);
  22. }
  23. export declare class PgTimestamp<T extends ColumnBaseConfig<'date', 'PgTimestamp'>> extends PgColumn<T> {
  24. static readonly [entityKind]: string;
  25. readonly withTimezone: boolean;
  26. readonly precision: number | undefined;
  27. constructor(table: AnyPgTable<{
  28. name: T['tableName'];
  29. }>, config: PgTimestampBuilder<T>['config']);
  30. getSQLType(): string;
  31. mapFromDriverValue(value: Date | string): Date;
  32. mapToDriverValue: (value: Date) => string;
  33. }
  34. export type PgTimestampStringBuilderInitial<TName extends string> = PgTimestampStringBuilder<{
  35. name: TName;
  36. dataType: 'string';
  37. columnType: 'PgTimestampString';
  38. data: string;
  39. driverParam: string;
  40. enumValues: undefined;
  41. }>;
  42. export declare class PgTimestampStringBuilder<T extends ColumnBuilderBaseConfig<'string', 'PgTimestampString'>> extends PgDateColumnBaseBuilder<T, {
  43. withTimezone: boolean;
  44. precision: number | undefined;
  45. }> {
  46. static readonly [entityKind]: string;
  47. constructor(name: T['name'], withTimezone: boolean, precision: number | undefined);
  48. }
  49. export declare class PgTimestampString<T extends ColumnBaseConfig<'string', 'PgTimestampString'>> extends PgColumn<T> {
  50. static readonly [entityKind]: string;
  51. readonly withTimezone: boolean;
  52. readonly precision: number | undefined;
  53. constructor(table: AnyPgTable<{
  54. name: T['tableName'];
  55. }>, config: PgTimestampStringBuilder<T>['config']);
  56. getSQLType(): string;
  57. mapFromDriverValue(value: Date | string): string;
  58. }
  59. export type Precision = 0 | 1 | 2 | 3 | 4 | 5 | 6;
  60. export interface PgTimestampConfig<TMode extends 'date' | 'string' = 'date' | 'string'> {
  61. mode?: TMode;
  62. precision?: Precision;
  63. withTimezone?: boolean;
  64. }
  65. export declare function timestamp(): PgTimestampBuilderInitial<''>;
  66. export declare function timestamp<TMode extends PgTimestampConfig['mode'] & {}>(config?: PgTimestampConfig<TMode>): Equal<TMode, 'string'> extends true ? PgTimestampStringBuilderInitial<''> : PgTimestampBuilderInitial<''>;
  67. export declare function timestamp<TName extends string, TMode extends PgTimestampConfig['mode'] & {}>(name: TName, config?: PgTimestampConfig<TMode>): Equal<TMode, 'string'> extends true ? PgTimestampStringBuilderInitial<TName> : PgTimestampBuilderInitial<TName>;