hysteria-orm 10.9.7 → 10.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.cts CHANGED
@@ -2754,6 +2754,12 @@ type LazyRelationType = {
2754
2754
  wasModelProvided: boolean;
2755
2755
  };
2756
2756
  };
2757
+ /**
2758
+ * Callback type for autoCreate/autoUpdate hooks on date columns.
2759
+ * Returns `Date` when used with date-mode columns (e.g. `col.datetime()`),
2760
+ * returns `string` when used with string-mode columns (e.g. `col.datetime.string()`).
2761
+ */
2762
+ type DateAutoHook = (() => Date) | (() => string);
2757
2763
  type DateColumnOptions = {
2758
2764
  /**
2759
2765
  * @description The format to store dates in ('ISO' or 'TIMESTAMP')
@@ -2767,17 +2773,19 @@ type DateColumnOptions = {
2767
2773
  timezone?: Timezone;
2768
2774
  /**
2769
2775
  * @description Whether to automatically update the timestamp on record updates, uses timezone and format from the dateColumn options
2776
+ * @description If true, uses the default implementation (current date). If a callback, calls it to get the value.
2770
2777
  * @warning This is a code wise implementation it does not generate a trigger in the database, works with bulk updates too
2771
2778
  * @default false
2772
2779
  */
2773
- autoUpdate?: boolean;
2780
+ autoUpdate?: boolean | DateAutoHook;
2774
2781
  /**
2775
2782
  * @description Whether to automatically set the timestamp on record creation, uses timezone and format from the dateColumn options
2783
+ * @description If true, uses the default implementation (current date). If a callback, calls it to get the value.
2776
2784
  * @warning This is a code wise implementation it does not generate a trigger in the database, works with bulk creations too
2777
2785
  * @default false
2778
2786
  */
2779
- autoCreate?: boolean;
2780
- } & ColumnOptions;
2787
+ autoCreate?: boolean | DateAutoHook;
2788
+ } & Omit<ColumnOptions, "serialize" | "prepare" | "autoUpdate">;
2781
2789
  /**
2782
2790
  * @description Options for @column.datetime and @column.timestamp decorators.
2783
2791
  * Extends DateColumnOptions with date-specific options (precision, withTimezone).
@@ -6478,10 +6486,11 @@ type ColDecimalOptions = Omit<ColumnOptions, "serialize" | "prepare" | "default"
6478
6486
  type ColIncrementOptions = Omit<ColumnOptions, "serialize" | "prepare" | "primaryKey" | "nullable" | "default">;
6479
6487
  type ColBigIncrementOptions = Omit<ColumnOptions, "serialize" | "prepare" | "primaryKey" | "nullable" | "default">;
6480
6488
  type ColBooleanOptions = Omit<ColumnOptions, "prepare" | "serialize" | "default">;
6481
- type ColDateOptions = Omit<DateColumnOptions, "format" | "serialize" | "prepare" | "default">;
6482
- type ColDatetimeOptions = Omit<DatetimeColumnOptions, "serialize" | "prepare" | "default">;
6483
- type ColTimestampOptions = Omit<DatetimeColumnOptions, "serialize" | "prepare" | "default">;
6484
- type ColTimeOptions = Omit<DateColumnOptions, "format" | "serialize" | "prepare" | "default">;
6489
+ type ColDateOptions = Omit<DateColumnOptions, "format" | "default">;
6490
+ type ColDatetimeOptions = Omit<DatetimeColumnOptions, "default">;
6491
+ type ColTimestampOptions = Omit<DatetimeColumnOptions, "default">;
6492
+ type ColTimeOptions = Omit<DateColumnOptions, "format" | "default">;
6493
+
6485
6494
  type ColJsonOptions = Omit<ColumnOptions, "prepare" | "serialize" | "default">;
6486
6495
  type ColJsonbOptions = Omit<ColumnOptions, "prepare" | "serialize" | "default">;
6487
6496
  type ColUuidOptions = Omit<ColumnOptions, "prepare" | "serialize" | "default">;
@@ -6624,109 +6633,117 @@ interface ColNamespace {
6624
6633
  */
6625
6634
  boolean<O extends ColBooleanOptions = ColBooleanOptions>(options?: O & TypedDefault<boolean>): ColumnDef<NullableColumn<boolean, O>>;
6626
6635
  /**
6627
- * DATE column (YYYY-MM-DD). Defaults to `Date` because database drivers
6628
- * return `Date` objects.
6636
+ * DATE column (YYYY-MM-DD). Returns `Date` objects.
6629
6637
  *
6630
- * Pass a `serialize` function to type the column as `string` instead:
6638
+ * Use `col.date.string()` to get string values instead.
6631
6639
  *
6632
6640
  * ```ts
6633
- * col.date({ nullable: false, serialize: (raw) => raw.toISOString().split("T")[0] }) // string
6634
- * col.date({ nullable: false }) // Date
6635
- * col.date({ serialize: (raw) => raw.toISOString().split("T")[0] }) // string | null
6636
- * col.date() // Date | null
6641
+ * col.date({ nullable: false }) // Date
6642
+ * col.date() // Date | null
6643
+ * col.date.string() // string | null
6644
+ * col.date.string({ nullable: false }) // string
6637
6645
  * ```
6638
- * @warning Serialize functions for Date columns can only return a string
6639
6646
  */
6640
- date(options: ColDateOptions & {
6641
- nullable: false;
6642
- } & {
6643
- serialize: (value: any) => string;
6644
- } & TypedPrepare<string> & TypedDefault<string>): ColumnDef<string>;
6645
- date(options: ColDateOptions & {
6646
- nullable: false;
6647
- } & TypedPrepare<Date> & TypedDefault<string>): ColumnDef<Date>;
6648
- date(options: ColDateOptions & {
6649
- serialize: (value: any) => string | null;
6650
- } & TypedPrepare<string | null> & TypedDefault<string>): ColumnDef<string | null>;
6651
- date(options?: ColDateOptions & TypedPrepare<Date | null> & TypedDefault<string>): ColumnDef<Date | null>;
6652
- /**
6653
- * DATETIME column. Defaults to `Date` because database drivers return
6654
- * `Date` objects.
6647
+ date: {
6648
+ (options: ColDateOptions & {
6649
+ nullable: false;
6650
+ }): ColumnDef<Date>;
6651
+ (options?: ColDateOptions): ColumnDef<Date | null>;
6652
+ /**
6653
+ * DATE column (YYYY-MM-DD) typed as `string`.
6654
+ * Values are passed through untouched as strings.
6655
+ */
6656
+ string: {
6657
+ (options: ColDateOptions & {
6658
+ nullable: false;
6659
+ }): ColumnDef<string>;
6660
+ (options?: ColDateOptions): ColumnDef<string | null>;
6661
+ };
6662
+ };
6663
+ /**
6664
+ * DATETIME column. Returns `Date` objects.
6655
6665
  *
6656
- * Pass a `serialize` function to type the column as `string` instead:
6666
+ * Use `col.datetime.string()` to get string values instead.
6657
6667
  *
6658
6668
  * ```ts
6659
- * col.datetime({ nullable: false, serialize: (raw) => new Date(raw).toISOString() }) // string
6660
- * col.datetime({ nullable: false }) // Date
6661
- * col.datetime({ serialize: (raw) => new Date(raw).toISOString() }) // string | null
6662
- * col.datetime() // Date | null
6669
+ * col.datetime({ nullable: false }) // Date
6670
+ * col.datetime() // Date | null
6671
+ * col.datetime.string() // string | null
6672
+ * col.datetime.string({ nullable: false }) // string
6663
6673
  * ```
6664
- * @warning Serialize functions for Date columns can only return a string
6665
6674
  */
6666
- datetime(options: ColDatetimeOptions & {
6667
- nullable: false;
6668
- } & {
6669
- serialize: (value: any) => string;
6670
- } & TypedPrepare<string> & TypedDefault<string>): ColumnDef<string>;
6671
- datetime(options: ColDatetimeOptions & {
6672
- nullable: false;
6673
- } & TypedPrepare<Date> & TypedDefault<string>): ColumnDef<Date>;
6674
- datetime(options: ColDatetimeOptions & {
6675
- serialize: (value: any) => string | null;
6676
- } & TypedPrepare<string | null> & TypedDefault<string>): ColumnDef<string | null>;
6677
- datetime(options?: ColDatetimeOptions & TypedPrepare<Date | null> & TypedDefault<string>): ColumnDef<Date | null>;
6678
- /**
6679
- * TIMESTAMP column. Defaults to `Date` because database drivers return
6680
- * `Date` objects.
6675
+ datetime: {
6676
+ (options: ColDatetimeOptions & {
6677
+ nullable: false;
6678
+ }): ColumnDef<Date>;
6679
+ (options?: ColDatetimeOptions): ColumnDef<Date | null>;
6680
+ /**
6681
+ * DATETIME column typed as `string`.
6682
+ * Values are passed through untouched as strings.
6683
+ */
6684
+ string: {
6685
+ (options: ColDatetimeOptions & {
6686
+ nullable: false;
6687
+ }): ColumnDef<string>;
6688
+ (options?: ColDatetimeOptions): ColumnDef<string | null>;
6689
+ };
6690
+ };
6691
+ /**
6692
+ * TIMESTAMP column. Returns `Date` objects.
6681
6693
  *
6682
- * Pass a `serialize` function to type the column as `string` instead:
6694
+ * Use `col.timestamp.string()` to get string values instead.
6683
6695
  *
6684
6696
  * ```ts
6685
- * col.timestamp({ nullable: false, serialize: (raw) => new Date(raw).toISOString() }) // string
6686
- * col.timestamp({ nullable: false }) // Date
6687
- * col.timestamp({ serialize: (raw) => new Date(raw).toISOString() }) // string | null
6688
- * col.timestamp() // Date | null
6697
+ * col.timestamp({ nullable: false }) // Date
6698
+ * col.timestamp() // Date | null
6699
+ * col.timestamp.string() // string | null
6700
+ * col.timestamp.string({ nullable: false }) // string
6689
6701
  * ```
6690
- * @warning Serialize functions for Date columns can only return a string
6691
6702
  */
6692
- timestamp(options: ColTimestampOptions & {
6693
- nullable: false;
6694
- } & {
6695
- serialize: (value: any) => string;
6696
- } & TypedPrepare<string> & TypedDefault<string>): ColumnDef<string>;
6697
- timestamp(options: ColTimestampOptions & {
6698
- nullable: false;
6699
- } & TypedPrepare<Date> & TypedDefault<string>): ColumnDef<Date>;
6700
- timestamp(options: ColTimestampOptions & {
6701
- serialize: (value: any) => string | null;
6702
- } & TypedPrepare<string | null> & TypedDefault<string>): ColumnDef<string | null>;
6703
- timestamp(options?: ColTimestampOptions & TypedPrepare<Date | null> & TypedDefault<string>): ColumnDef<Date | null>;
6704
- /**
6705
- * TIME column. Defaults to `Date` because database drivers return
6706
- * `Date` objects.
6703
+ timestamp: {
6704
+ (options: ColTimestampOptions & {
6705
+ nullable: false;
6706
+ }): ColumnDef<Date>;
6707
+ (options?: ColTimestampOptions): ColumnDef<Date | null>;
6708
+ /**
6709
+ * TIMESTAMP column typed as `string`.
6710
+ * Values are passed through untouched as strings.
6711
+ */
6712
+ string: {
6713
+ (options: ColTimestampOptions & {
6714
+ nullable: false;
6715
+ }): ColumnDef<string>;
6716
+ (options?: ColTimestampOptions): ColumnDef<string | null>;
6717
+ };
6718
+ };
6719
+ /**
6720
+ * TIME column (HH:mm:ss). Returns `Date` objects.
6707
6721
  *
6708
- * Pass a `serialize` function to type the column as `string` instead:
6722
+ * Use `col.time.string()` to get string values instead.
6709
6723
  *
6710
6724
  * ```ts
6711
- * col.time({ nullable: false, serialize: (raw) => new Date(raw).toTimeString() }) // string
6712
- * col.time({ nullable: false }) // Date
6713
- * col.time({ serialize: (raw) => new Date(raw).toTimeString() }) // string | null
6714
- * col.time() // Date | null
6725
+ * col.time({ nullable: false }) // Date
6726
+ * col.time() // Date | null
6727
+ * col.time.string() // string | null
6728
+ * col.time.string({ nullable: false }) // string
6715
6729
  * ```
6716
- * @warning Serialize functions for Date columns can only return a string
6717
6730
  */
6718
- time(options: ColTimeOptions & {
6719
- nullable: false;
6720
- } & {
6721
- serialize: (value: any) => string;
6722
- } & TypedPrepare<string> & TypedDefault<string>): ColumnDef<string>;
6723
- time(options: ColTimeOptions & {
6724
- nullable: false;
6725
- } & TypedPrepare<Date> & TypedDefault<string>): ColumnDef<Date>;
6726
- time(options: ColTimeOptions & {
6727
- serialize: (value: any) => string | null;
6728
- } & TypedPrepare<string | null> & TypedDefault<string>): ColumnDef<string | null>;
6729
- time(options?: ColTimeOptions & TypedPrepare<Date | null> & TypedDefault<string>): ColumnDef<Date | null>;
6731
+ time: {
6732
+ (options: ColTimeOptions & {
6733
+ nullable: false;
6734
+ }): ColumnDef<Date>;
6735
+ (options?: ColTimeOptions): ColumnDef<Date | null>;
6736
+ /**
6737
+ * TIME column (HH:mm:ss) typed as `string`.
6738
+ * Values are passed through untouched as strings.
6739
+ */
6740
+ string: {
6741
+ (options: ColTimeOptions & {
6742
+ nullable: false;
6743
+ }): ColumnDef<string>;
6744
+ (options?: ColTimeOptions): ColumnDef<string | null>;
6745
+ };
6746
+ };
6730
6747
  /**
6731
6748
  * JSON column (`type: "json"`). Defaults to `unknown`.
6732
6749
  * Pass a concrete type for structured JSON data: `col.json<MyType>()`.
@@ -8255,4 +8272,4 @@ declare const generateOpenApiModelWithMetadata: <T extends new () => Model>(mode
8255
8272
  $id?: string;
8256
8273
  }>;
8257
8274
 
8258
- export { type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AnyModelConstructor, type BaseModelMethodOptions, BaseSeeder, type BuildSelectType, type BuildSingleSelectType, type CacheAdapter, type CacheKeys, ClientMigrator, type ColCharOptions, type ColJsonbOptions, type ColMediumIntOptions, type ColSmallIntOptions, type ColTinyIntOptions, type ColVarbinaryOptions, Collection, type CollectionDefinition, type ColumnDef, type CommonDataSourceInput, type ComposeBuildSelect, type ComposeSelect, type ConnectionPolicies, type CreateSchemaResult, type CustomLogger, type DataSourceInput, type DataSourceType, type DefinedCollection, type DefinedModel, type DefinedView, type ExcludeMethods, type ExtractColumnName, type ExtractSourceColumn, type FetchHooks, type FindReturnType, type GetColumnType, type GetConnectionReturnType, HysteriaError, InMemoryAdapter, type InferPK, type LoadOptions, type LoggerConfig, type ManyOptions, Migration, type MigrationConfig, type MigrationConfigBase, type ModelDataProperties, type ModelInstanceType, type ModelKey, ModelQueryBuilder, type ModelQueryResult, type ModelRelation, type ModelSelectTuple, type ModelSelectableInput, type ModelWithoutRelations, type ModelsProxy, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MutationReturningResult, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleDBDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NullableColumn, type NumberModelKey, type OneOptions, type OracleDBDataSourceInput, type OracleDBPoolInstance, type PgPoolClientInstance, type PostgresSqlDataSourceInput, type PrimaryColumnDef, type PropNamespace, type PropertyDef, QueryBuilder, type RawModelKey, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationDef, type RelationDefinitions, type RelationHelpers, type RelationLoadStrategy, type RelationQueryBuilderType, type ReplicationType, type ReturningColumns, type ReturningKey, type ReturningParam, type ReturningResult, type ReturningResultMany, type ReturningSupported, Schema, SchemaBuilder, type SchemaLookup, type SchemaRelDef, type SeederConfig, type SelectBrand, type SelectableColumn$1 as SelectableColumn, type SelectedModel, type SlaveAlgorithm, type SlaveContext, type SqlCloneOptions, SqlDataSource, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDriverSpecificOptions, type SqlPoolType, type Sqlite3ConnectionOptions, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type StripTablePrefix, type SubQueryable, type TableFormat, Transaction, type TransactionExecutionOptions, type TypedDefault, type TypedPrepare, type TypedSerialize, type UseCacheReturnType, type UseConnectionInput, type ViewDefinition, WriteOperation, type WriteReturnType, col, createSchema, defineCollection, defineMigrator, defineModel, defineModelFactory, defineRelations, defineView, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, type getPoolReturnType, HysteriaLogger as logger, prop, RedisDataSource as redis, withPerformance };
8275
+ export { type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AnyModelConstructor, type BaseModelMethodOptions, BaseSeeder, type BuildSelectType, type BuildSingleSelectType, type CacheAdapter, type CacheKeys, ClientMigrator, type ColCharOptions, type ColJsonbOptions, type ColMediumIntOptions, type ColSmallIntOptions, type ColTinyIntOptions, type ColVarbinaryOptions, Collection, type CollectionDefinition, type ColumnDef, type CommonDataSourceInput, type ComposeBuildSelect, type ComposeSelect, type ConnectionPolicies, type CreateSchemaResult, type CustomLogger, type DataSourceInput, type DataSourceType, type DateAutoHook, type DefinedCollection, type DefinedModel, type DefinedView, type ExcludeMethods, type ExtractColumnName, type ExtractSourceColumn, type FetchHooks, type FindReturnType, type GetColumnType, type GetConnectionReturnType, HysteriaError, InMemoryAdapter, type InferPK, type LoadOptions, type LoggerConfig, type ManyOptions, Migration, type MigrationConfig, type MigrationConfigBase, type ModelDataProperties, type ModelInstanceType, type ModelKey, ModelQueryBuilder, type ModelQueryResult, type ModelRelation, type ModelSelectTuple, type ModelSelectableInput, type ModelWithoutRelations, type ModelsProxy, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MutationReturningResult, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleDBDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NullableColumn, type NumberModelKey, type OneOptions, type OracleDBDataSourceInput, type OracleDBPoolInstance, type PgPoolClientInstance, type PostgresSqlDataSourceInput, type PrimaryColumnDef, type PropNamespace, type PropertyDef, QueryBuilder, type RawModelKey, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationDef, type RelationDefinitions, type RelationHelpers, type RelationLoadStrategy, type RelationQueryBuilderType, type ReplicationType, type ReturningColumns, type ReturningKey, type ReturningParam, type ReturningResult, type ReturningResultMany, type ReturningSupported, Schema, SchemaBuilder, type SchemaLookup, type SchemaRelDef, type SeederConfig, type SelectBrand, type SelectableColumn$1 as SelectableColumn, type SelectedModel, type SlaveAlgorithm, type SlaveContext, type SqlCloneOptions, SqlDataSource, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDriverSpecificOptions, type SqlPoolType, type Sqlite3ConnectionOptions, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type StripTablePrefix, type SubQueryable, type TableFormat, Transaction, type TransactionExecutionOptions, type TypedDefault, type TypedPrepare, type TypedSerialize, type UseCacheReturnType, type UseConnectionInput, type ViewDefinition, WriteOperation, type WriteReturnType, col, createSchema, defineCollection, defineMigrator, defineModel, defineModelFactory, defineRelations, defineView, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, type getPoolReturnType, HysteriaLogger as logger, prop, RedisDataSource as redis, withPerformance };
package/lib/index.d.ts CHANGED
@@ -2754,6 +2754,12 @@ type LazyRelationType = {
2754
2754
  wasModelProvided: boolean;
2755
2755
  };
2756
2756
  };
2757
+ /**
2758
+ * Callback type for autoCreate/autoUpdate hooks on date columns.
2759
+ * Returns `Date` when used with date-mode columns (e.g. `col.datetime()`),
2760
+ * returns `string` when used with string-mode columns (e.g. `col.datetime.string()`).
2761
+ */
2762
+ type DateAutoHook = (() => Date) | (() => string);
2757
2763
  type DateColumnOptions = {
2758
2764
  /**
2759
2765
  * @description The format to store dates in ('ISO' or 'TIMESTAMP')
@@ -2767,17 +2773,19 @@ type DateColumnOptions = {
2767
2773
  timezone?: Timezone;
2768
2774
  /**
2769
2775
  * @description Whether to automatically update the timestamp on record updates, uses timezone and format from the dateColumn options
2776
+ * @description If true, uses the default implementation (current date). If a callback, calls it to get the value.
2770
2777
  * @warning This is a code wise implementation it does not generate a trigger in the database, works with bulk updates too
2771
2778
  * @default false
2772
2779
  */
2773
- autoUpdate?: boolean;
2780
+ autoUpdate?: boolean | DateAutoHook;
2774
2781
  /**
2775
2782
  * @description Whether to automatically set the timestamp on record creation, uses timezone and format from the dateColumn options
2783
+ * @description If true, uses the default implementation (current date). If a callback, calls it to get the value.
2776
2784
  * @warning This is a code wise implementation it does not generate a trigger in the database, works with bulk creations too
2777
2785
  * @default false
2778
2786
  */
2779
- autoCreate?: boolean;
2780
- } & ColumnOptions;
2787
+ autoCreate?: boolean | DateAutoHook;
2788
+ } & Omit<ColumnOptions, "serialize" | "prepare" | "autoUpdate">;
2781
2789
  /**
2782
2790
  * @description Options for @column.datetime and @column.timestamp decorators.
2783
2791
  * Extends DateColumnOptions with date-specific options (precision, withTimezone).
@@ -6478,10 +6486,11 @@ type ColDecimalOptions = Omit<ColumnOptions, "serialize" | "prepare" | "default"
6478
6486
  type ColIncrementOptions = Omit<ColumnOptions, "serialize" | "prepare" | "primaryKey" | "nullable" | "default">;
6479
6487
  type ColBigIncrementOptions = Omit<ColumnOptions, "serialize" | "prepare" | "primaryKey" | "nullable" | "default">;
6480
6488
  type ColBooleanOptions = Omit<ColumnOptions, "prepare" | "serialize" | "default">;
6481
- type ColDateOptions = Omit<DateColumnOptions, "format" | "serialize" | "prepare" | "default">;
6482
- type ColDatetimeOptions = Omit<DatetimeColumnOptions, "serialize" | "prepare" | "default">;
6483
- type ColTimestampOptions = Omit<DatetimeColumnOptions, "serialize" | "prepare" | "default">;
6484
- type ColTimeOptions = Omit<DateColumnOptions, "format" | "serialize" | "prepare" | "default">;
6489
+ type ColDateOptions = Omit<DateColumnOptions, "format" | "default">;
6490
+ type ColDatetimeOptions = Omit<DatetimeColumnOptions, "default">;
6491
+ type ColTimestampOptions = Omit<DatetimeColumnOptions, "default">;
6492
+ type ColTimeOptions = Omit<DateColumnOptions, "format" | "default">;
6493
+
6485
6494
  type ColJsonOptions = Omit<ColumnOptions, "prepare" | "serialize" | "default">;
6486
6495
  type ColJsonbOptions = Omit<ColumnOptions, "prepare" | "serialize" | "default">;
6487
6496
  type ColUuidOptions = Omit<ColumnOptions, "prepare" | "serialize" | "default">;
@@ -6624,109 +6633,117 @@ interface ColNamespace {
6624
6633
  */
6625
6634
  boolean<O extends ColBooleanOptions = ColBooleanOptions>(options?: O & TypedDefault<boolean>): ColumnDef<NullableColumn<boolean, O>>;
6626
6635
  /**
6627
- * DATE column (YYYY-MM-DD). Defaults to `Date` because database drivers
6628
- * return `Date` objects.
6636
+ * DATE column (YYYY-MM-DD). Returns `Date` objects.
6629
6637
  *
6630
- * Pass a `serialize` function to type the column as `string` instead:
6638
+ * Use `col.date.string()` to get string values instead.
6631
6639
  *
6632
6640
  * ```ts
6633
- * col.date({ nullable: false, serialize: (raw) => raw.toISOString().split("T")[0] }) // string
6634
- * col.date({ nullable: false }) // Date
6635
- * col.date({ serialize: (raw) => raw.toISOString().split("T")[0] }) // string | null
6636
- * col.date() // Date | null
6641
+ * col.date({ nullable: false }) // Date
6642
+ * col.date() // Date | null
6643
+ * col.date.string() // string | null
6644
+ * col.date.string({ nullable: false }) // string
6637
6645
  * ```
6638
- * @warning Serialize functions for Date columns can only return a string
6639
6646
  */
6640
- date(options: ColDateOptions & {
6641
- nullable: false;
6642
- } & {
6643
- serialize: (value: any) => string;
6644
- } & TypedPrepare<string> & TypedDefault<string>): ColumnDef<string>;
6645
- date(options: ColDateOptions & {
6646
- nullable: false;
6647
- } & TypedPrepare<Date> & TypedDefault<string>): ColumnDef<Date>;
6648
- date(options: ColDateOptions & {
6649
- serialize: (value: any) => string | null;
6650
- } & TypedPrepare<string | null> & TypedDefault<string>): ColumnDef<string | null>;
6651
- date(options?: ColDateOptions & TypedPrepare<Date | null> & TypedDefault<string>): ColumnDef<Date | null>;
6652
- /**
6653
- * DATETIME column. Defaults to `Date` because database drivers return
6654
- * `Date` objects.
6647
+ date: {
6648
+ (options: ColDateOptions & {
6649
+ nullable: false;
6650
+ }): ColumnDef<Date>;
6651
+ (options?: ColDateOptions): ColumnDef<Date | null>;
6652
+ /**
6653
+ * DATE column (YYYY-MM-DD) typed as `string`.
6654
+ * Values are passed through untouched as strings.
6655
+ */
6656
+ string: {
6657
+ (options: ColDateOptions & {
6658
+ nullable: false;
6659
+ }): ColumnDef<string>;
6660
+ (options?: ColDateOptions): ColumnDef<string | null>;
6661
+ };
6662
+ };
6663
+ /**
6664
+ * DATETIME column. Returns `Date` objects.
6655
6665
  *
6656
- * Pass a `serialize` function to type the column as `string` instead:
6666
+ * Use `col.datetime.string()` to get string values instead.
6657
6667
  *
6658
6668
  * ```ts
6659
- * col.datetime({ nullable: false, serialize: (raw) => new Date(raw).toISOString() }) // string
6660
- * col.datetime({ nullable: false }) // Date
6661
- * col.datetime({ serialize: (raw) => new Date(raw).toISOString() }) // string | null
6662
- * col.datetime() // Date | null
6669
+ * col.datetime({ nullable: false }) // Date
6670
+ * col.datetime() // Date | null
6671
+ * col.datetime.string() // string | null
6672
+ * col.datetime.string({ nullable: false }) // string
6663
6673
  * ```
6664
- * @warning Serialize functions for Date columns can only return a string
6665
6674
  */
6666
- datetime(options: ColDatetimeOptions & {
6667
- nullable: false;
6668
- } & {
6669
- serialize: (value: any) => string;
6670
- } & TypedPrepare<string> & TypedDefault<string>): ColumnDef<string>;
6671
- datetime(options: ColDatetimeOptions & {
6672
- nullable: false;
6673
- } & TypedPrepare<Date> & TypedDefault<string>): ColumnDef<Date>;
6674
- datetime(options: ColDatetimeOptions & {
6675
- serialize: (value: any) => string | null;
6676
- } & TypedPrepare<string | null> & TypedDefault<string>): ColumnDef<string | null>;
6677
- datetime(options?: ColDatetimeOptions & TypedPrepare<Date | null> & TypedDefault<string>): ColumnDef<Date | null>;
6678
- /**
6679
- * TIMESTAMP column. Defaults to `Date` because database drivers return
6680
- * `Date` objects.
6675
+ datetime: {
6676
+ (options: ColDatetimeOptions & {
6677
+ nullable: false;
6678
+ }): ColumnDef<Date>;
6679
+ (options?: ColDatetimeOptions): ColumnDef<Date | null>;
6680
+ /**
6681
+ * DATETIME column typed as `string`.
6682
+ * Values are passed through untouched as strings.
6683
+ */
6684
+ string: {
6685
+ (options: ColDatetimeOptions & {
6686
+ nullable: false;
6687
+ }): ColumnDef<string>;
6688
+ (options?: ColDatetimeOptions): ColumnDef<string | null>;
6689
+ };
6690
+ };
6691
+ /**
6692
+ * TIMESTAMP column. Returns `Date` objects.
6681
6693
  *
6682
- * Pass a `serialize` function to type the column as `string` instead:
6694
+ * Use `col.timestamp.string()` to get string values instead.
6683
6695
  *
6684
6696
  * ```ts
6685
- * col.timestamp({ nullable: false, serialize: (raw) => new Date(raw).toISOString() }) // string
6686
- * col.timestamp({ nullable: false }) // Date
6687
- * col.timestamp({ serialize: (raw) => new Date(raw).toISOString() }) // string | null
6688
- * col.timestamp() // Date | null
6697
+ * col.timestamp({ nullable: false }) // Date
6698
+ * col.timestamp() // Date | null
6699
+ * col.timestamp.string() // string | null
6700
+ * col.timestamp.string({ nullable: false }) // string
6689
6701
  * ```
6690
- * @warning Serialize functions for Date columns can only return a string
6691
6702
  */
6692
- timestamp(options: ColTimestampOptions & {
6693
- nullable: false;
6694
- } & {
6695
- serialize: (value: any) => string;
6696
- } & TypedPrepare<string> & TypedDefault<string>): ColumnDef<string>;
6697
- timestamp(options: ColTimestampOptions & {
6698
- nullable: false;
6699
- } & TypedPrepare<Date> & TypedDefault<string>): ColumnDef<Date>;
6700
- timestamp(options: ColTimestampOptions & {
6701
- serialize: (value: any) => string | null;
6702
- } & TypedPrepare<string | null> & TypedDefault<string>): ColumnDef<string | null>;
6703
- timestamp(options?: ColTimestampOptions & TypedPrepare<Date | null> & TypedDefault<string>): ColumnDef<Date | null>;
6704
- /**
6705
- * TIME column. Defaults to `Date` because database drivers return
6706
- * `Date` objects.
6703
+ timestamp: {
6704
+ (options: ColTimestampOptions & {
6705
+ nullable: false;
6706
+ }): ColumnDef<Date>;
6707
+ (options?: ColTimestampOptions): ColumnDef<Date | null>;
6708
+ /**
6709
+ * TIMESTAMP column typed as `string`.
6710
+ * Values are passed through untouched as strings.
6711
+ */
6712
+ string: {
6713
+ (options: ColTimestampOptions & {
6714
+ nullable: false;
6715
+ }): ColumnDef<string>;
6716
+ (options?: ColTimestampOptions): ColumnDef<string | null>;
6717
+ };
6718
+ };
6719
+ /**
6720
+ * TIME column (HH:mm:ss). Returns `Date` objects.
6707
6721
  *
6708
- * Pass a `serialize` function to type the column as `string` instead:
6722
+ * Use `col.time.string()` to get string values instead.
6709
6723
  *
6710
6724
  * ```ts
6711
- * col.time({ nullable: false, serialize: (raw) => new Date(raw).toTimeString() }) // string
6712
- * col.time({ nullable: false }) // Date
6713
- * col.time({ serialize: (raw) => new Date(raw).toTimeString() }) // string | null
6714
- * col.time() // Date | null
6725
+ * col.time({ nullable: false }) // Date
6726
+ * col.time() // Date | null
6727
+ * col.time.string() // string | null
6728
+ * col.time.string({ nullable: false }) // string
6715
6729
  * ```
6716
- * @warning Serialize functions for Date columns can only return a string
6717
6730
  */
6718
- time(options: ColTimeOptions & {
6719
- nullable: false;
6720
- } & {
6721
- serialize: (value: any) => string;
6722
- } & TypedPrepare<string> & TypedDefault<string>): ColumnDef<string>;
6723
- time(options: ColTimeOptions & {
6724
- nullable: false;
6725
- } & TypedPrepare<Date> & TypedDefault<string>): ColumnDef<Date>;
6726
- time(options: ColTimeOptions & {
6727
- serialize: (value: any) => string | null;
6728
- } & TypedPrepare<string | null> & TypedDefault<string>): ColumnDef<string | null>;
6729
- time(options?: ColTimeOptions & TypedPrepare<Date | null> & TypedDefault<string>): ColumnDef<Date | null>;
6731
+ time: {
6732
+ (options: ColTimeOptions & {
6733
+ nullable: false;
6734
+ }): ColumnDef<Date>;
6735
+ (options?: ColTimeOptions): ColumnDef<Date | null>;
6736
+ /**
6737
+ * TIME column (HH:mm:ss) typed as `string`.
6738
+ * Values are passed through untouched as strings.
6739
+ */
6740
+ string: {
6741
+ (options: ColTimeOptions & {
6742
+ nullable: false;
6743
+ }): ColumnDef<string>;
6744
+ (options?: ColTimeOptions): ColumnDef<string | null>;
6745
+ };
6746
+ };
6730
6747
  /**
6731
6748
  * JSON column (`type: "json"`). Defaults to `unknown`.
6732
6749
  * Pass a concrete type for structured JSON data: `col.json<MyType>()`.
@@ -8255,4 +8272,4 @@ declare const generateOpenApiModelWithMetadata: <T extends new () => Model>(mode
8255
8272
  $id?: string;
8256
8273
  }>;
8257
8274
 
8258
- export { type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AnyModelConstructor, type BaseModelMethodOptions, BaseSeeder, type BuildSelectType, type BuildSingleSelectType, type CacheAdapter, type CacheKeys, ClientMigrator, type ColCharOptions, type ColJsonbOptions, type ColMediumIntOptions, type ColSmallIntOptions, type ColTinyIntOptions, type ColVarbinaryOptions, Collection, type CollectionDefinition, type ColumnDef, type CommonDataSourceInput, type ComposeBuildSelect, type ComposeSelect, type ConnectionPolicies, type CreateSchemaResult, type CustomLogger, type DataSourceInput, type DataSourceType, type DefinedCollection, type DefinedModel, type DefinedView, type ExcludeMethods, type ExtractColumnName, type ExtractSourceColumn, type FetchHooks, type FindReturnType, type GetColumnType, type GetConnectionReturnType, HysteriaError, InMemoryAdapter, type InferPK, type LoadOptions, type LoggerConfig, type ManyOptions, Migration, type MigrationConfig, type MigrationConfigBase, type ModelDataProperties, type ModelInstanceType, type ModelKey, ModelQueryBuilder, type ModelQueryResult, type ModelRelation, type ModelSelectTuple, type ModelSelectableInput, type ModelWithoutRelations, type ModelsProxy, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MutationReturningResult, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleDBDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NullableColumn, type NumberModelKey, type OneOptions, type OracleDBDataSourceInput, type OracleDBPoolInstance, type PgPoolClientInstance, type PostgresSqlDataSourceInput, type PrimaryColumnDef, type PropNamespace, type PropertyDef, QueryBuilder, type RawModelKey, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationDef, type RelationDefinitions, type RelationHelpers, type RelationLoadStrategy, type RelationQueryBuilderType, type ReplicationType, type ReturningColumns, type ReturningKey, type ReturningParam, type ReturningResult, type ReturningResultMany, type ReturningSupported, Schema, SchemaBuilder, type SchemaLookup, type SchemaRelDef, type SeederConfig, type SelectBrand, type SelectableColumn$1 as SelectableColumn, type SelectedModel, type SlaveAlgorithm, type SlaveContext, type SqlCloneOptions, SqlDataSource, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDriverSpecificOptions, type SqlPoolType, type Sqlite3ConnectionOptions, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type StripTablePrefix, type SubQueryable, type TableFormat, Transaction, type TransactionExecutionOptions, type TypedDefault, type TypedPrepare, type TypedSerialize, type UseCacheReturnType, type UseConnectionInput, type ViewDefinition, WriteOperation, type WriteReturnType, col, createSchema, defineCollection, defineMigrator, defineModel, defineModelFactory, defineRelations, defineView, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, type getPoolReturnType, HysteriaLogger as logger, prop, RedisDataSource as redis, withPerformance };
8275
+ export { type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AnyModelConstructor, type BaseModelMethodOptions, BaseSeeder, type BuildSelectType, type BuildSingleSelectType, type CacheAdapter, type CacheKeys, ClientMigrator, type ColCharOptions, type ColJsonbOptions, type ColMediumIntOptions, type ColSmallIntOptions, type ColTinyIntOptions, type ColVarbinaryOptions, Collection, type CollectionDefinition, type ColumnDef, type CommonDataSourceInput, type ComposeBuildSelect, type ComposeSelect, type ConnectionPolicies, type CreateSchemaResult, type CustomLogger, type DataSourceInput, type DataSourceType, type DateAutoHook, type DefinedCollection, type DefinedModel, type DefinedView, type ExcludeMethods, type ExtractColumnName, type ExtractSourceColumn, type FetchHooks, type FindReturnType, type GetColumnType, type GetConnectionReturnType, HysteriaError, InMemoryAdapter, type InferPK, type LoadOptions, type LoggerConfig, type ManyOptions, Migration, type MigrationConfig, type MigrationConfigBase, type ModelDataProperties, type ModelInstanceType, type ModelKey, ModelQueryBuilder, type ModelQueryResult, type ModelRelation, type ModelSelectTuple, type ModelSelectableInput, type ModelWithoutRelations, type ModelsProxy, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MutationReturningResult, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleDBDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NullableColumn, type NumberModelKey, type OneOptions, type OracleDBDataSourceInput, type OracleDBPoolInstance, type PgPoolClientInstance, type PostgresSqlDataSourceInput, type PrimaryColumnDef, type PropNamespace, type PropertyDef, QueryBuilder, type RawModelKey, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationDef, type RelationDefinitions, type RelationHelpers, type RelationLoadStrategy, type RelationQueryBuilderType, type ReplicationType, type ReturningColumns, type ReturningKey, type ReturningParam, type ReturningResult, type ReturningResultMany, type ReturningSupported, Schema, SchemaBuilder, type SchemaLookup, type SchemaRelDef, type SeederConfig, type SelectBrand, type SelectableColumn$1 as SelectableColumn, type SelectedModel, type SlaveAlgorithm, type SlaveContext, type SqlCloneOptions, SqlDataSource, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDriverSpecificOptions, type SqlPoolType, type Sqlite3ConnectionOptions, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type StripTablePrefix, type SubQueryable, type TableFormat, Transaction, type TransactionExecutionOptions, type TypedDefault, type TypedPrepare, type TypedSerialize, type UseCacheReturnType, type UseConnectionInput, type ViewDefinition, WriteOperation, type WriteReturnType, col, createSchema, defineCollection, defineMigrator, defineModel, defineModelFactory, defineRelations, defineView, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, type getPoolReturnType, HysteriaLogger as logger, prop, RedisDataSource as redis, withPerformance };