hysteria-orm 10.0.6 → 10.0.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
@@ -1382,16 +1382,81 @@ declare class InterpreterUtils {
1382
1382
  * @description Formats the table name for the database type, idempotent for quoting
1383
1383
  */
1384
1384
  formatStringTable(dbType: SqlDataSourceType, table: string): string;
1385
- prepareColumns(columns: string[], values: any[], mode?: "insert" | "update"): {
1385
+ prepareColumns(columns: string[], values: any[], mode?: "insert" | "update"): Promise<{
1386
1386
  columns: string[];
1387
1387
  values: any[];
1388
- };
1388
+ }>;
1389
1389
  /**
1390
1390
  * @description Formats the from node for write operations removing the "from" keyword
1391
1391
  */
1392
1392
  getFromForWriteOperations(dbType: SqlDataSourceType, fromNode: FromNode): string;
1393
1393
  }
1394
1394
 
1395
+ type DeleteOptions = {
1396
+ ignoreBeforeDeleteHook?: boolean;
1397
+ };
1398
+ type SoftDeleteOptions<T> = {
1399
+ column?: MongoCollectionKey<T>;
1400
+ value?: string | number | boolean;
1401
+ ignoreBeforeUpdateHook?: boolean;
1402
+ };
1403
+
1404
+ /**
1405
+ * Allows to get queries without executing them
1406
+ */
1407
+ declare class DryQueryBuilder extends QueryBuilder {
1408
+ constructor(model: typeof Model, sqlDataSource: SqlDataSource);
1409
+ many(): this;
1410
+ /**
1411
+ * @description Builds the insert query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
1412
+ * @param args The arguments to pass to the insert method
1413
+ * @warning This method does not run model or column hooks
1414
+ * @returns The query builder
1415
+ */
1416
+ insert(...args: Parameters<typeof QueryBuilder.prototype.insert>): this;
1417
+ /**
1418
+ * @description Builds the insert many query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
1419
+ * @param args The arguments to pass to the insert many method
1420
+ * @warning This method does not run model or column hooks
1421
+ * @returns The query builder
1422
+ */
1423
+ insertMany(...args: Parameters<typeof QueryBuilder.prototype.insertMany>): this;
1424
+ /**
1425
+ * @description Builds the upsert query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
1426
+ * @param args The arguments to pass to the upsert method
1427
+ * @warning This method does not run model or column hooks
1428
+ * @returns The query builder
1429
+ */
1430
+ upsert(...args: Parameters<typeof QueryBuilder.prototype.upsert>): this;
1431
+ upsertMany(...args: Parameters<typeof QueryBuilder.prototype.upsertMany>): this;
1432
+ /**
1433
+ * @description Builds the update query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
1434
+ * @param data The data to update
1435
+ * @warning This method does not run model or column hooks
1436
+ * @returns The query builder
1437
+ */
1438
+ update(data: Record<string, any>): this;
1439
+ /**
1440
+ * @description Builds the delete query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
1441
+ * @warning This method does not run model or column hooks
1442
+ * @returns The query builder
1443
+ */
1444
+ delete(): this;
1445
+ /**
1446
+ * @description Builds the truncate query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
1447
+ * @warning This method does not run model or column hooks
1448
+ * @returns The query builder
1449
+ */
1450
+ truncate(): this;
1451
+ /**
1452
+ * @description Builds the soft delete query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
1453
+ * @param options Soft delete options
1454
+ * @warning This method does not run model or column hooks
1455
+ * @returns The query builder
1456
+ */
1457
+ softDelete(options?: Omit<SoftDeleteOptions<any>, "ignoreBeforeDeleteHook">): this;
1458
+ }
1459
+
1395
1460
  type BaseValues$1 = string | number | boolean | null;
1396
1461
  type BinaryOperatorType$1 = "=" | "!=" | "<>" | ">" | "<" | ">=" | "<=" | "like" | "ilike" | "in";
1397
1462
  declare class HavingNode extends QueryNode {
@@ -1707,8 +1772,8 @@ ColumnDataTypeOption;
1707
1772
  type ColumnType = {
1708
1773
  columnName: string;
1709
1774
  databaseName: string;
1710
- serialize?: (value: any) => any;
1711
- prepare?: (value: any) => any;
1775
+ serialize?: (value: any) => any | Promise<any>;
1776
+ prepare?: (value: any) => any | Promise<any>;
1712
1777
  hidden?: boolean;
1713
1778
  autoUpdate?: boolean;
1714
1779
  isPrimary: boolean;
@@ -2405,6 +2470,8 @@ type UpsertOptionsRawBuilder = {
2405
2470
  updateOnConflict?: boolean;
2406
2471
  returning?: string[];
2407
2472
  };
2473
+ type DryQueryBuilderWithoutReadOperations = Omit<DryQueryBuilder, "many" | "one" | "oneOrFail" | "first" | "firstOrFail" | "paginate" | "paginateWithCursor" | "exists" | "pluck" | "increment" | "decrement" | "getSum" | "getAvg" | "getMin" | "getMax" | "getCount" | "stream" | "chunk" | "paginate" | "paginateWithCursor" | "exists">;
2474
+ type DryModelQueryBuilderWithoutReadOperations<T extends Model, A extends Record<string, any> = {}, R extends Record<string, any> = {}> = Omit<DryModelQueryBuilder<T, A, R>, "many" | "one" | "oneOrFail" | "first" | "firstOrFail" | "paginate" | "paginateWithCursor" | "exists" | "pluck" | "upsert" | "upsertMany" | "increment" | "decrement" | "getSum" | "getAvg" | "getMin" | "getMax" | "getCount" | "stream" | "chunk" | "paginate" | "paginateWithCursor" | "exists">;
2408
2475
 
2409
2476
  declare class SqlModelManagerUtils<T extends Model> {
2410
2477
  protected dbType: SqlDataSourceType;
@@ -2440,15 +2507,6 @@ type CursorPaginatedData<T extends Model, A extends object = {}, R extends objec
2440
2507
  data: AnnotatedModel<T, A, R>[];
2441
2508
  };
2442
2509
 
2443
- type DeleteOptions = {
2444
- ignoreBeforeDeleteHook?: boolean;
2445
- };
2446
- type SoftDeleteOptions<T> = {
2447
- column?: MongoCollectionKey<T>;
2448
- value?: string | number | boolean;
2449
- ignoreBeforeDeleteHook?: boolean;
2450
- };
2451
-
2452
2510
  type UpdateOptions = {
2453
2511
  ignoreBeforeUpdateHook?: boolean;
2454
2512
  };
@@ -2826,6 +2884,53 @@ declare class ModelQueryBuilder<T extends Model, A extends Record<string, any> =
2826
2884
  private truncateWithPerformance;
2827
2885
  }
2828
2886
 
2887
+ /**
2888
+ * Allows to get model queries without executing them
2889
+ */
2890
+ declare class DryModelQueryBuilder<T extends Model, A extends Record<string, any> = {}, R extends Record<string, any> = {}> extends ModelQueryBuilder<T, A, R> {
2891
+ constructor(model: typeof Model, sqlDataSource: SqlDataSource);
2892
+ many(): this;
2893
+ /**
2894
+ * @description Builds the insert query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
2895
+ * @param args The arguments to pass to the insert method
2896
+ * @warning This method does not run model or column hooks
2897
+ * @returns The query builder
2898
+ */
2899
+ insert(...args: Parameters<typeof this$1.model.insert<T>>): this;
2900
+ /**
2901
+ * @description Builds the insert many query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
2902
+ * @param args The arguments to pass to the insert many method
2903
+ * @warning This method does not run model or column hooks
2904
+ * @returns The query builder
2905
+ */
2906
+ insertMany(...args: Parameters<typeof this$1.model.insertMany<T>>): this;
2907
+ /**
2908
+ * @description Builds the update query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
2909
+ * @param data The data to update
2910
+ * @warning This method does not run model or column hooks
2911
+ * @returns The query builder
2912
+ */
2913
+ update(...args: Parameters<ReturnType<typeof this$1.model.query<T>>["update"]>): this;
2914
+ /**
2915
+ * @description Builds the delete query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
2916
+ * @param options Delete options
2917
+ * @returns The query builder
2918
+ */
2919
+ delete(...args: Parameters<ReturnType<typeof this$1.model.query<T>>["delete"]>): this;
2920
+ /**
2921
+ * @description Builds the truncate query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
2922
+ * @returns The query builder
2923
+ */
2924
+ truncate(): this;
2925
+ /**
2926
+ * @description Builds the soft delete query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
2927
+ * @param options Soft delete options
2928
+ * @warning This method does not run model or column hooks
2929
+ * @returns The query builder
2930
+ */
2931
+ softDelete(...args: Parameters<ReturnType<typeof this$1.model.query<T>>["softDelete"]>): this;
2932
+ }
2933
+
2829
2934
  declare class ModelManager<T extends Model> {
2830
2935
  protected sqlDataSource: SqlDataSource;
2831
2936
  protected sqlType: SqlDataSourceType;
@@ -2885,6 +2990,11 @@ declare class ModelManager<T extends Model> {
2885
2990
  * @description Returns a query builder instance
2886
2991
  */
2887
2992
  query(): Omit<ModelQueryBuilder<T>, "insert" | "insertMany">;
2993
+ /**
2994
+ * @description Returns a dry query builder instance
2995
+ * @description The dry query builder instance will not execute the query, it will return the query statement
2996
+ */
2997
+ dryQuery(): Omit<DryModelQueryBuilder<T>, "insert" | "insertMany">;
2888
2998
  /**
2889
2999
  * @description Mysql does not return the inserted model, so we need to get the inserted model from the database
2890
3000
  */
@@ -3008,6 +3118,12 @@ declare class SqlDataSource extends DataSource {
3008
3118
  * @param table The table name to query from, must be in valid sql format `table` or `table as alias`
3009
3119
  */
3010
3120
  static query<S extends string>(table: TableFormat<S>, options?: RawModelOptions): QueryBuilder;
3121
+ /**
3122
+ * @description Returns a dry query builder instance
3123
+ * @description The dry query builder instance will not execute the query, it will return the query statement
3124
+ * @returns The dry query builder instance
3125
+ */
3126
+ static dryQuery<S extends string>(table: TableFormat<S>, options?: RawModelOptions): DryQueryBuilderWithoutReadOperations;
3011
3127
  /**
3012
3128
  * @description Creates a table on the database, return the query to be executed to create the table
3013
3129
  */
@@ -3102,6 +3218,12 @@ declare class SqlDataSource extends DataSource {
3102
3218
  * @param table The table name to query from, must be in valid sql format `table` or `table as alias`
3103
3219
  */
3104
3220
  query<S extends string>(table: TableFormat<S>, options?: RawModelOptions): QueryBuilder;
3221
+ /**
3222
+ * @description Returns a DryQueryBuilder instance
3223
+ * @description The dry query builder instance will not execute the query, it will return the query statement
3224
+ * @returns The dry query builder instance
3225
+ */
3226
+ dryQuery<S extends string>(table: TableFormat<S>, options?: RawModelOptions): DryQueryBuilderWithoutReadOperations;
3105
3227
  /**
3106
3228
  * @description Return the query to alter the given table schema
3107
3229
  */
@@ -3349,6 +3471,19 @@ declare class InsertNode extends QueryNode {
3349
3471
  constructor(fromNode: FromNode, records?: Record<string, any>[], returning?: string[], disableReturning?: boolean, isRawValue?: boolean);
3350
3472
  }
3351
3473
 
3474
+ declare class OnDuplicateNode extends QueryNode {
3475
+ table: string;
3476
+ conflictColumns: string[];
3477
+ columnsToUpdate: string[];
3478
+ returning?: string[];
3479
+ mode: "update" | "ignore";
3480
+ chainsWith: string;
3481
+ canKeywordBeSeenMultipleTimes: boolean;
3482
+ folder: string;
3483
+ file: string;
3484
+ constructor(table: string, conflictColumns: string[], columnsToUpdate: string[], mode?: "update" | "ignore", returning?: string[], isRawValue?: boolean);
3485
+ }
3486
+
3352
3487
  declare class TruncateNode extends QueryNode {
3353
3488
  fromNode: FromNode | string;
3354
3489
  chainsWith: string;
@@ -3379,6 +3514,7 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
3379
3514
  protected mustRemoveAnnotations: boolean;
3380
3515
  protected interpreterUtils: InterpreterUtils;
3381
3516
  protected insertNode: InsertNode | null;
3517
+ protected onDuplicateNode: OnDuplicateNode | null;
3382
3518
  protected updateNode: UpdateNode | null;
3383
3519
  protected deleteNode: DeleteNode | null;
3384
3520
  protected truncateNode: TruncateNode | null;
@@ -3483,7 +3619,7 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
3483
3619
  * @postgres needs the pg-query-stream package in order to work
3484
3620
  * @throws If using postgres and the `pg-query-stream` package is not installed
3485
3621
  */
3486
- stream<M extends Model = T>(options?: StreamOptions, cb?: (stream: PassThrough & AsyncGenerator<AnnotatedModel<M, any, any>>) => void | Promise<void>): Promise<PassThrough & AsyncGenerator<AnnotatedModel<M, {}, {}>>>;
3622
+ stream<M extends Model = T>(options?: StreamOptions): Promise<PassThrough & AsyncGenerator<AnnotatedModel<M, {}, {}>>>;
3487
3623
  /**
3488
3624
  * @description Chunks the query into smaller queries, it returns a generator of the chunks
3489
3625
  * @description It will continue to yield chunks until the query returns no results
@@ -3674,11 +3810,11 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
3674
3810
  /**
3675
3811
  * @description Returns the query with the parameters bound to the query
3676
3812
  */
3677
- toQuery(dbType?: SqlDataSourceType): string;
3813
+ toQuery(): string;
3678
3814
  /**
3679
3815
  * @description Returns the query with database driver placeholders and the params
3680
3816
  */
3681
- unWrap(_dbType?: SqlDataSourceType): ReturnType<typeof AstParser.prototype.parse>;
3817
+ unWrap(): ReturnType<typeof AstParser.prototype.parse>;
3682
3818
  /**
3683
3819
  * @description Returns a deep clone of the query builder instance.
3684
3820
  */
@@ -3911,6 +4047,11 @@ declare abstract class Model extends Entity {
3911
4047
  * @description Gives a query sqlInstance for the given model
3912
4048
  */
3913
4049
  static query<T extends Model>(this: new () => T | typeof Model, options?: Omit<BaseModelMethodOptions, "ignoreHooks">): ModelQueryBuilder<T>;
4050
+ /**
4051
+ * @description Returns a dry query builder instance
4052
+ * @description The dry query builder instance will not execute the query
4053
+ */
4054
+ static dryQuery<T extends Model>(this: new () => T | typeof Model, options?: Omit<BaseModelMethodOptions, "ignoreHooks">): DryModelQueryBuilderWithoutReadOperations<T>;
3914
4055
  /**
3915
4056
  * @description Finds the first record in the database
3916
4057
  * @deprecated Used only for debugging purposes, use findOne or query instead
@@ -5185,4 +5326,4 @@ declare const generateOpenApiModelWithMetadata: <T extends new () => Model>(mode
5185
5326
  modelName: string;
5186
5327
  }>;
5187
5328
 
5188
- export { type AnnotatedModel, type AsymmetricEncryptionOptions, type AugmentedSqlDataSource, AutogeneratedModel, type BaseModelMethodOptions, type BaseModelRelationType, ClientMigrator, Collection, type ColumnDataTypeOption, type ColumnDataTypeOptionSimple, type ColumnDataTypeOptionWithBinary, type ColumnDataTypeOptionWithDatePrecision, type ColumnDataTypeOptionWithEnum, type ColumnDataTypeOptionWithLength, type ColumnDataTypeOptionWithPrecision, type ColumnDataTypeOptionWithScaleAndPrecision, type ColumnDataTypeOptionWithText, type ColumnOptions, type ColumnType, type CommonDataSourceInput, type CommonSqlMethodReturnType, type ConnectionPolicies, type DataSourceInput, type DataSourceType, type DateColumnOptions, type FetchHooks, type GetConnectionReturnType, HysteriaError, type IndexType, type LazyRelationType, type ManyOptions, type ManyToManyOptions, Migration, Model, type ModelInstanceType, ModelQueryBuilder, type ModelWithoutRelations, MongoDataSource, type MongoDataSourceInput, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NumberModelKey, type OneOptions, type PgPoolClientInstance, type PostgresSqlDataSourceInput, QueryBuilder, type RawModelOptions, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationQueryBuilderType, type SqlCloneOptions, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDataSourceWithoutTransaction, type SqlDriverSpecificOptions, type SqlPoolType, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type SymmetricEncryptionOptions, type TableFormat, type ThroughModel, TimestampedModel, Transaction, type TransactionExecutionOptions, type UniqueType, type UseConnectionInput, User, UuidModel, belongsTo, column, createModelFactory, defineMigrator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, getCollectionProperties, getIndexes, getModelColumns, type getPoolReturnType, getPrimaryKey, getRelations, getRelationsMetadata, getUniques, hasMany, hasOne, index, HysteriaLogger as logger, manyToMany, MongoDataSource as mongo, property, RedisDataSource as redis, SqlDataSource as sql, unique, view, withPerformance };
5329
+ export { type AnnotatedModel, type AsymmetricEncryptionOptions, type AugmentedSqlDataSource, AutogeneratedModel, type BaseModelMethodOptions, type BaseModelRelationType, ClientMigrator, Collection, type ColumnDataTypeOption, type ColumnDataTypeOptionSimple, type ColumnDataTypeOptionWithBinary, type ColumnDataTypeOptionWithDatePrecision, type ColumnDataTypeOptionWithEnum, type ColumnDataTypeOptionWithLength, type ColumnDataTypeOptionWithPrecision, type ColumnDataTypeOptionWithScaleAndPrecision, type ColumnDataTypeOptionWithText, type ColumnOptions, type ColumnType, type CommonDataSourceInput, type CommonSqlMethodReturnType, type ConnectionPolicies, type DataSourceInput, type DataSourceType, type DateColumnOptions, DryModelQueryBuilder, DryQueryBuilder, type FetchHooks, type GetConnectionReturnType, HysteriaError, type IndexType, type LazyRelationType, type ManyOptions, type ManyToManyOptions, Migration, Model, type ModelInstanceType, ModelQueryBuilder, type ModelWithoutRelations, MongoDataSource, type MongoDataSourceInput, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NumberModelKey, type OneOptions, type PgPoolClientInstance, type PostgresSqlDataSourceInput, QueryBuilder, type RawModelOptions, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationQueryBuilderType, type SqlCloneOptions, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDataSourceWithoutTransaction, type SqlDriverSpecificOptions, type SqlPoolType, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type SymmetricEncryptionOptions, type TableFormat, type ThroughModel, TimestampedModel, Transaction, type TransactionExecutionOptions, type UniqueType, type UseConnectionInput, User, UuidModel, belongsTo, column, createModelFactory, defineMigrator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, getCollectionProperties, getIndexes, getModelColumns, type getPoolReturnType, getPrimaryKey, getRelations, getRelationsMetadata, getUniques, hasMany, hasOne, index, HysteriaLogger as logger, manyToMany, MongoDataSource as mongo, property, RedisDataSource as redis, SqlDataSource as sql, unique, view, withPerformance };
package/lib/index.d.ts CHANGED
@@ -1382,16 +1382,81 @@ declare class InterpreterUtils {
1382
1382
  * @description Formats the table name for the database type, idempotent for quoting
1383
1383
  */
1384
1384
  formatStringTable(dbType: SqlDataSourceType, table: string): string;
1385
- prepareColumns(columns: string[], values: any[], mode?: "insert" | "update"): {
1385
+ prepareColumns(columns: string[], values: any[], mode?: "insert" | "update"): Promise<{
1386
1386
  columns: string[];
1387
1387
  values: any[];
1388
- };
1388
+ }>;
1389
1389
  /**
1390
1390
  * @description Formats the from node for write operations removing the "from" keyword
1391
1391
  */
1392
1392
  getFromForWriteOperations(dbType: SqlDataSourceType, fromNode: FromNode): string;
1393
1393
  }
1394
1394
 
1395
+ type DeleteOptions = {
1396
+ ignoreBeforeDeleteHook?: boolean;
1397
+ };
1398
+ type SoftDeleteOptions<T> = {
1399
+ column?: MongoCollectionKey<T>;
1400
+ value?: string | number | boolean;
1401
+ ignoreBeforeUpdateHook?: boolean;
1402
+ };
1403
+
1404
+ /**
1405
+ * Allows to get queries without executing them
1406
+ */
1407
+ declare class DryQueryBuilder extends QueryBuilder {
1408
+ constructor(model: typeof Model, sqlDataSource: SqlDataSource);
1409
+ many(): this;
1410
+ /**
1411
+ * @description Builds the insert query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
1412
+ * @param args The arguments to pass to the insert method
1413
+ * @warning This method does not run model or column hooks
1414
+ * @returns The query builder
1415
+ */
1416
+ insert(...args: Parameters<typeof QueryBuilder.prototype.insert>): this;
1417
+ /**
1418
+ * @description Builds the insert many query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
1419
+ * @param args The arguments to pass to the insert many method
1420
+ * @warning This method does not run model or column hooks
1421
+ * @returns The query builder
1422
+ */
1423
+ insertMany(...args: Parameters<typeof QueryBuilder.prototype.insertMany>): this;
1424
+ /**
1425
+ * @description Builds the upsert query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
1426
+ * @param args The arguments to pass to the upsert method
1427
+ * @warning This method does not run model or column hooks
1428
+ * @returns The query builder
1429
+ */
1430
+ upsert(...args: Parameters<typeof QueryBuilder.prototype.upsert>): this;
1431
+ upsertMany(...args: Parameters<typeof QueryBuilder.prototype.upsertMany>): this;
1432
+ /**
1433
+ * @description Builds the update query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
1434
+ * @param data The data to update
1435
+ * @warning This method does not run model or column hooks
1436
+ * @returns The query builder
1437
+ */
1438
+ update(data: Record<string, any>): this;
1439
+ /**
1440
+ * @description Builds the delete query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
1441
+ * @warning This method does not run model or column hooks
1442
+ * @returns The query builder
1443
+ */
1444
+ delete(): this;
1445
+ /**
1446
+ * @description Builds the truncate query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
1447
+ * @warning This method does not run model or column hooks
1448
+ * @returns The query builder
1449
+ */
1450
+ truncate(): this;
1451
+ /**
1452
+ * @description Builds the soft delete query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
1453
+ * @param options Soft delete options
1454
+ * @warning This method does not run model or column hooks
1455
+ * @returns The query builder
1456
+ */
1457
+ softDelete(options?: Omit<SoftDeleteOptions<any>, "ignoreBeforeDeleteHook">): this;
1458
+ }
1459
+
1395
1460
  type BaseValues$1 = string | number | boolean | null;
1396
1461
  type BinaryOperatorType$1 = "=" | "!=" | "<>" | ">" | "<" | ">=" | "<=" | "like" | "ilike" | "in";
1397
1462
  declare class HavingNode extends QueryNode {
@@ -1707,8 +1772,8 @@ ColumnDataTypeOption;
1707
1772
  type ColumnType = {
1708
1773
  columnName: string;
1709
1774
  databaseName: string;
1710
- serialize?: (value: any) => any;
1711
- prepare?: (value: any) => any;
1775
+ serialize?: (value: any) => any | Promise<any>;
1776
+ prepare?: (value: any) => any | Promise<any>;
1712
1777
  hidden?: boolean;
1713
1778
  autoUpdate?: boolean;
1714
1779
  isPrimary: boolean;
@@ -2405,6 +2470,8 @@ type UpsertOptionsRawBuilder = {
2405
2470
  updateOnConflict?: boolean;
2406
2471
  returning?: string[];
2407
2472
  };
2473
+ type DryQueryBuilderWithoutReadOperations = Omit<DryQueryBuilder, "many" | "one" | "oneOrFail" | "first" | "firstOrFail" | "paginate" | "paginateWithCursor" | "exists" | "pluck" | "increment" | "decrement" | "getSum" | "getAvg" | "getMin" | "getMax" | "getCount" | "stream" | "chunk" | "paginate" | "paginateWithCursor" | "exists">;
2474
+ type DryModelQueryBuilderWithoutReadOperations<T extends Model, A extends Record<string, any> = {}, R extends Record<string, any> = {}> = Omit<DryModelQueryBuilder<T, A, R>, "many" | "one" | "oneOrFail" | "first" | "firstOrFail" | "paginate" | "paginateWithCursor" | "exists" | "pluck" | "upsert" | "upsertMany" | "increment" | "decrement" | "getSum" | "getAvg" | "getMin" | "getMax" | "getCount" | "stream" | "chunk" | "paginate" | "paginateWithCursor" | "exists">;
2408
2475
 
2409
2476
  declare class SqlModelManagerUtils<T extends Model> {
2410
2477
  protected dbType: SqlDataSourceType;
@@ -2440,15 +2507,6 @@ type CursorPaginatedData<T extends Model, A extends object = {}, R extends objec
2440
2507
  data: AnnotatedModel<T, A, R>[];
2441
2508
  };
2442
2509
 
2443
- type DeleteOptions = {
2444
- ignoreBeforeDeleteHook?: boolean;
2445
- };
2446
- type SoftDeleteOptions<T> = {
2447
- column?: MongoCollectionKey<T>;
2448
- value?: string | number | boolean;
2449
- ignoreBeforeDeleteHook?: boolean;
2450
- };
2451
-
2452
2510
  type UpdateOptions = {
2453
2511
  ignoreBeforeUpdateHook?: boolean;
2454
2512
  };
@@ -2826,6 +2884,53 @@ declare class ModelQueryBuilder<T extends Model, A extends Record<string, any> =
2826
2884
  private truncateWithPerformance;
2827
2885
  }
2828
2886
 
2887
+ /**
2888
+ * Allows to get model queries without executing them
2889
+ */
2890
+ declare class DryModelQueryBuilder<T extends Model, A extends Record<string, any> = {}, R extends Record<string, any> = {}> extends ModelQueryBuilder<T, A, R> {
2891
+ constructor(model: typeof Model, sqlDataSource: SqlDataSource);
2892
+ many(): this;
2893
+ /**
2894
+ * @description Builds the insert query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
2895
+ * @param args The arguments to pass to the insert method
2896
+ * @warning This method does not run model or column hooks
2897
+ * @returns The query builder
2898
+ */
2899
+ insert(...args: Parameters<typeof this$1.model.insert<T>>): this;
2900
+ /**
2901
+ * @description Builds the insert many query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
2902
+ * @param args The arguments to pass to the insert many method
2903
+ * @warning This method does not run model or column hooks
2904
+ * @returns The query builder
2905
+ */
2906
+ insertMany(...args: Parameters<typeof this$1.model.insertMany<T>>): this;
2907
+ /**
2908
+ * @description Builds the update query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
2909
+ * @param data The data to update
2910
+ * @warning This method does not run model or column hooks
2911
+ * @returns The query builder
2912
+ */
2913
+ update(...args: Parameters<ReturnType<typeof this$1.model.query<T>>["update"]>): this;
2914
+ /**
2915
+ * @description Builds the delete query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
2916
+ * @param options Delete options
2917
+ * @returns The query builder
2918
+ */
2919
+ delete(...args: Parameters<ReturnType<typeof this$1.model.query<T>>["delete"]>): this;
2920
+ /**
2921
+ * @description Builds the truncate query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
2922
+ * @returns The query builder
2923
+ */
2924
+ truncate(): this;
2925
+ /**
2926
+ * @description Builds the soft delete query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
2927
+ * @param options Soft delete options
2928
+ * @warning This method does not run model or column hooks
2929
+ * @returns The query builder
2930
+ */
2931
+ softDelete(...args: Parameters<ReturnType<typeof this$1.model.query<T>>["softDelete"]>): this;
2932
+ }
2933
+
2829
2934
  declare class ModelManager<T extends Model> {
2830
2935
  protected sqlDataSource: SqlDataSource;
2831
2936
  protected sqlType: SqlDataSourceType;
@@ -2885,6 +2990,11 @@ declare class ModelManager<T extends Model> {
2885
2990
  * @description Returns a query builder instance
2886
2991
  */
2887
2992
  query(): Omit<ModelQueryBuilder<T>, "insert" | "insertMany">;
2993
+ /**
2994
+ * @description Returns a dry query builder instance
2995
+ * @description The dry query builder instance will not execute the query, it will return the query statement
2996
+ */
2997
+ dryQuery(): Omit<DryModelQueryBuilder<T>, "insert" | "insertMany">;
2888
2998
  /**
2889
2999
  * @description Mysql does not return the inserted model, so we need to get the inserted model from the database
2890
3000
  */
@@ -3008,6 +3118,12 @@ declare class SqlDataSource extends DataSource {
3008
3118
  * @param table The table name to query from, must be in valid sql format `table` or `table as alias`
3009
3119
  */
3010
3120
  static query<S extends string>(table: TableFormat<S>, options?: RawModelOptions): QueryBuilder;
3121
+ /**
3122
+ * @description Returns a dry query builder instance
3123
+ * @description The dry query builder instance will not execute the query, it will return the query statement
3124
+ * @returns The dry query builder instance
3125
+ */
3126
+ static dryQuery<S extends string>(table: TableFormat<S>, options?: RawModelOptions): DryQueryBuilderWithoutReadOperations;
3011
3127
  /**
3012
3128
  * @description Creates a table on the database, return the query to be executed to create the table
3013
3129
  */
@@ -3102,6 +3218,12 @@ declare class SqlDataSource extends DataSource {
3102
3218
  * @param table The table name to query from, must be in valid sql format `table` or `table as alias`
3103
3219
  */
3104
3220
  query<S extends string>(table: TableFormat<S>, options?: RawModelOptions): QueryBuilder;
3221
+ /**
3222
+ * @description Returns a DryQueryBuilder instance
3223
+ * @description The dry query builder instance will not execute the query, it will return the query statement
3224
+ * @returns The dry query builder instance
3225
+ */
3226
+ dryQuery<S extends string>(table: TableFormat<S>, options?: RawModelOptions): DryQueryBuilderWithoutReadOperations;
3105
3227
  /**
3106
3228
  * @description Return the query to alter the given table schema
3107
3229
  */
@@ -3349,6 +3471,19 @@ declare class InsertNode extends QueryNode {
3349
3471
  constructor(fromNode: FromNode, records?: Record<string, any>[], returning?: string[], disableReturning?: boolean, isRawValue?: boolean);
3350
3472
  }
3351
3473
 
3474
+ declare class OnDuplicateNode extends QueryNode {
3475
+ table: string;
3476
+ conflictColumns: string[];
3477
+ columnsToUpdate: string[];
3478
+ returning?: string[];
3479
+ mode: "update" | "ignore";
3480
+ chainsWith: string;
3481
+ canKeywordBeSeenMultipleTimes: boolean;
3482
+ folder: string;
3483
+ file: string;
3484
+ constructor(table: string, conflictColumns: string[], columnsToUpdate: string[], mode?: "update" | "ignore", returning?: string[], isRawValue?: boolean);
3485
+ }
3486
+
3352
3487
  declare class TruncateNode extends QueryNode {
3353
3488
  fromNode: FromNode | string;
3354
3489
  chainsWith: string;
@@ -3379,6 +3514,7 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
3379
3514
  protected mustRemoveAnnotations: boolean;
3380
3515
  protected interpreterUtils: InterpreterUtils;
3381
3516
  protected insertNode: InsertNode | null;
3517
+ protected onDuplicateNode: OnDuplicateNode | null;
3382
3518
  protected updateNode: UpdateNode | null;
3383
3519
  protected deleteNode: DeleteNode | null;
3384
3520
  protected truncateNode: TruncateNode | null;
@@ -3483,7 +3619,7 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
3483
3619
  * @postgres needs the pg-query-stream package in order to work
3484
3620
  * @throws If using postgres and the `pg-query-stream` package is not installed
3485
3621
  */
3486
- stream<M extends Model = T>(options?: StreamOptions, cb?: (stream: PassThrough & AsyncGenerator<AnnotatedModel<M, any, any>>) => void | Promise<void>): Promise<PassThrough & AsyncGenerator<AnnotatedModel<M, {}, {}>>>;
3622
+ stream<M extends Model = T>(options?: StreamOptions): Promise<PassThrough & AsyncGenerator<AnnotatedModel<M, {}, {}>>>;
3487
3623
  /**
3488
3624
  * @description Chunks the query into smaller queries, it returns a generator of the chunks
3489
3625
  * @description It will continue to yield chunks until the query returns no results
@@ -3674,11 +3810,11 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
3674
3810
  /**
3675
3811
  * @description Returns the query with the parameters bound to the query
3676
3812
  */
3677
- toQuery(dbType?: SqlDataSourceType): string;
3813
+ toQuery(): string;
3678
3814
  /**
3679
3815
  * @description Returns the query with database driver placeholders and the params
3680
3816
  */
3681
- unWrap(_dbType?: SqlDataSourceType): ReturnType<typeof AstParser.prototype.parse>;
3817
+ unWrap(): ReturnType<typeof AstParser.prototype.parse>;
3682
3818
  /**
3683
3819
  * @description Returns a deep clone of the query builder instance.
3684
3820
  */
@@ -3911,6 +4047,11 @@ declare abstract class Model extends Entity {
3911
4047
  * @description Gives a query sqlInstance for the given model
3912
4048
  */
3913
4049
  static query<T extends Model>(this: new () => T | typeof Model, options?: Omit<BaseModelMethodOptions, "ignoreHooks">): ModelQueryBuilder<T>;
4050
+ /**
4051
+ * @description Returns a dry query builder instance
4052
+ * @description The dry query builder instance will not execute the query
4053
+ */
4054
+ static dryQuery<T extends Model>(this: new () => T | typeof Model, options?: Omit<BaseModelMethodOptions, "ignoreHooks">): DryModelQueryBuilderWithoutReadOperations<T>;
3914
4055
  /**
3915
4056
  * @description Finds the first record in the database
3916
4057
  * @deprecated Used only for debugging purposes, use findOne or query instead
@@ -5185,4 +5326,4 @@ declare const generateOpenApiModelWithMetadata: <T extends new () => Model>(mode
5185
5326
  modelName: string;
5186
5327
  }>;
5187
5328
 
5188
- export { type AnnotatedModel, type AsymmetricEncryptionOptions, type AugmentedSqlDataSource, AutogeneratedModel, type BaseModelMethodOptions, type BaseModelRelationType, ClientMigrator, Collection, type ColumnDataTypeOption, type ColumnDataTypeOptionSimple, type ColumnDataTypeOptionWithBinary, type ColumnDataTypeOptionWithDatePrecision, type ColumnDataTypeOptionWithEnum, type ColumnDataTypeOptionWithLength, type ColumnDataTypeOptionWithPrecision, type ColumnDataTypeOptionWithScaleAndPrecision, type ColumnDataTypeOptionWithText, type ColumnOptions, type ColumnType, type CommonDataSourceInput, type CommonSqlMethodReturnType, type ConnectionPolicies, type DataSourceInput, type DataSourceType, type DateColumnOptions, type FetchHooks, type GetConnectionReturnType, HysteriaError, type IndexType, type LazyRelationType, type ManyOptions, type ManyToManyOptions, Migration, Model, type ModelInstanceType, ModelQueryBuilder, type ModelWithoutRelations, MongoDataSource, type MongoDataSourceInput, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NumberModelKey, type OneOptions, type PgPoolClientInstance, type PostgresSqlDataSourceInput, QueryBuilder, type RawModelOptions, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationQueryBuilderType, type SqlCloneOptions, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDataSourceWithoutTransaction, type SqlDriverSpecificOptions, type SqlPoolType, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type SymmetricEncryptionOptions, type TableFormat, type ThroughModel, TimestampedModel, Transaction, type TransactionExecutionOptions, type UniqueType, type UseConnectionInput, User, UuidModel, belongsTo, column, createModelFactory, defineMigrator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, getCollectionProperties, getIndexes, getModelColumns, type getPoolReturnType, getPrimaryKey, getRelations, getRelationsMetadata, getUniques, hasMany, hasOne, index, HysteriaLogger as logger, manyToMany, MongoDataSource as mongo, property, RedisDataSource as redis, SqlDataSource as sql, unique, view, withPerformance };
5329
+ export { type AnnotatedModel, type AsymmetricEncryptionOptions, type AugmentedSqlDataSource, AutogeneratedModel, type BaseModelMethodOptions, type BaseModelRelationType, ClientMigrator, Collection, type ColumnDataTypeOption, type ColumnDataTypeOptionSimple, type ColumnDataTypeOptionWithBinary, type ColumnDataTypeOptionWithDatePrecision, type ColumnDataTypeOptionWithEnum, type ColumnDataTypeOptionWithLength, type ColumnDataTypeOptionWithPrecision, type ColumnDataTypeOptionWithScaleAndPrecision, type ColumnDataTypeOptionWithText, type ColumnOptions, type ColumnType, type CommonDataSourceInput, type CommonSqlMethodReturnType, type ConnectionPolicies, type DataSourceInput, type DataSourceType, type DateColumnOptions, DryModelQueryBuilder, DryQueryBuilder, type FetchHooks, type GetConnectionReturnType, HysteriaError, type IndexType, type LazyRelationType, type ManyOptions, type ManyToManyOptions, Migration, Model, type ModelInstanceType, ModelQueryBuilder, type ModelWithoutRelations, MongoDataSource, type MongoDataSourceInput, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NumberModelKey, type OneOptions, type PgPoolClientInstance, type PostgresSqlDataSourceInput, QueryBuilder, type RawModelOptions, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationQueryBuilderType, type SqlCloneOptions, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDataSourceWithoutTransaction, type SqlDriverSpecificOptions, type SqlPoolType, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type SymmetricEncryptionOptions, type TableFormat, type ThroughModel, TimestampedModel, Transaction, type TransactionExecutionOptions, type UniqueType, type UseConnectionInput, User, UuidModel, belongsTo, column, createModelFactory, defineMigrator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, getCollectionProperties, getIndexes, getModelColumns, type getPoolReturnType, getPrimaryKey, getRelations, getRelationsMetadata, getUniques, hasMany, hasOne, index, HysteriaLogger as logger, manyToMany, MongoDataSource as mongo, property, RedisDataSource as redis, SqlDataSource as sql, unique, view, withPerformance };