hysteria-orm 10.0.5 → 10.0.7

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
@@ -1392,6 +1392,63 @@ declare class InterpreterUtils {
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
+ * @returns The query builder
1414
+ */
1415
+ insert(...args: Parameters<typeof QueryBuilder.prototype.insert>): this;
1416
+ /**
1417
+ * @description Builds the insert many query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
1418
+ * @param args The arguments to pass to the insert many method
1419
+ * @returns The query builder
1420
+ */
1421
+ insertMany(...args: Parameters<typeof QueryBuilder.prototype.insertMany>): this;
1422
+ /**
1423
+ * @description Builds the upsert query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
1424
+ * @param args The arguments to pass to the upsert method
1425
+ * @returns The query builder
1426
+ */
1427
+ upsert(...args: Parameters<typeof QueryBuilder.prototype.upsert>): this;
1428
+ /**
1429
+ * @description Builds the update query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
1430
+ * @param data The data to update
1431
+ * @returns The query builder
1432
+ */
1433
+ update(data: Record<string, any>): this;
1434
+ /**
1435
+ * @description Builds the delete query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
1436
+ * @returns The query builder
1437
+ */
1438
+ delete(): this;
1439
+ /**
1440
+ * @description Builds the truncate query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
1441
+ * @returns The query builder
1442
+ */
1443
+ truncate(): this;
1444
+ /**
1445
+ * @description Builds the soft delete query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
1446
+ * @param options Soft delete options
1447
+ * @returns The query builder
1448
+ */
1449
+ softDelete(options?: Omit<SoftDeleteOptions<any>, "ignoreBeforeDeleteHook">): this;
1450
+ }
1451
+
1395
1452
  type BaseValues$1 = string | number | boolean | null;
1396
1453
  type BinaryOperatorType$1 = "=" | "!=" | "<>" | ">" | "<" | ">=" | "<=" | "like" | "ilike" | "in";
1397
1454
  declare class HavingNode extends QueryNode {
@@ -2401,6 +2458,12 @@ type PaginateWithCursorOptions<T extends Model, K extends ModelKey<T>> = {
2401
2458
  operator?: "<" | ">";
2402
2459
  orderBy?: "asc" | "desc";
2403
2460
  };
2461
+ type UpsertOptionsRawBuilder = {
2462
+ updateOnConflict?: boolean;
2463
+ returning?: string[];
2464
+ };
2465
+ type DryQueryBuilderWithoutReadOperations = Omit<DryQueryBuilder, "many" | "one" | "oneOrFail" | "first" | "firstOrFail" | "paginate" | "paginateWithCursor" | "exists" | "pluck" | "upsert" | "upsertMany" | "increment" | "decrement" | "getSum" | "getAvg" | "getMin" | "getMax" | "getCount" | "stream" | "chunk" | "paginate" | "paginateWithCursor" | "exists">;
2466
+ 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">;
2404
2467
 
2405
2468
  declare class SqlModelManagerUtils<T extends Model> {
2406
2469
  protected dbType: SqlDataSourceType;
@@ -2436,15 +2499,6 @@ type CursorPaginatedData<T extends Model, A extends object = {}, R extends objec
2436
2499
  data: AnnotatedModel<T, A, R>[];
2437
2500
  };
2438
2501
 
2439
- type DeleteOptions = {
2440
- ignoreBeforeDeleteHook?: boolean;
2441
- };
2442
- type SoftDeleteOptions<T> = {
2443
- column?: MongoCollectionKey<T>;
2444
- value?: string | number | boolean;
2445
- ignoreBeforeDeleteHook?: boolean;
2446
- };
2447
-
2448
2502
  type UpdateOptions = {
2449
2503
  ignoreBeforeUpdateHook?: boolean;
2450
2504
  };
@@ -2822,6 +2876,50 @@ declare class ModelQueryBuilder<T extends Model, A extends Record<string, any> =
2822
2876
  private truncateWithPerformance;
2823
2877
  }
2824
2878
 
2879
+ /**
2880
+ * Allows to get model queries without executing them
2881
+ */
2882
+ declare class DryModelQueryBuilder<T extends Model, A extends Record<string, any> = {}, R extends Record<string, any> = {}> extends ModelQueryBuilder<T, A, R> {
2883
+ constructor(model: typeof Model, sqlDataSource: SqlDataSource);
2884
+ many(): this;
2885
+ /**
2886
+ * @description Builds the insert query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
2887
+ * @param args The arguments to pass to the insert method
2888
+ * @returns The query builder
2889
+ */
2890
+ insert(...args: Parameters<typeof this$1.model.insert<T>>): this;
2891
+ /**
2892
+ * @description Builds the insert many query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
2893
+ * @param args The arguments to pass to the insert many method
2894
+ * @returns The query builder
2895
+ */
2896
+ insertMany(...args: Parameters<typeof this$1.model.insertMany<T>>): this;
2897
+ /**
2898
+ * @description Builds the update query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
2899
+ * @param data The data to update
2900
+ * @param options Update options
2901
+ * @returns The query builder
2902
+ */
2903
+ update(...args: Parameters<ReturnType<typeof this$1.model.query<T>>["update"]>): this;
2904
+ /**
2905
+ * @description Builds the delete query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
2906
+ * @param options Delete options
2907
+ * @returns The query builder
2908
+ */
2909
+ delete(...args: Parameters<ReturnType<typeof this$1.model.query<T>>["delete"]>): this;
2910
+ /**
2911
+ * @description Builds the truncate query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
2912
+ * @returns The query builder
2913
+ */
2914
+ truncate(): this;
2915
+ /**
2916
+ * @description Builds the soft delete query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
2917
+ * @param options Soft delete options
2918
+ * @returns The query builder
2919
+ */
2920
+ softDelete(...args: Parameters<ReturnType<typeof this$1.model.query<T>>["softDelete"]>): this;
2921
+ }
2922
+
2825
2923
  declare class ModelManager<T extends Model> {
2826
2924
  protected sqlDataSource: SqlDataSource;
2827
2925
  protected sqlType: SqlDataSourceType;
@@ -2881,6 +2979,11 @@ declare class ModelManager<T extends Model> {
2881
2979
  * @description Returns a query builder instance
2882
2980
  */
2883
2981
  query(): Omit<ModelQueryBuilder<T>, "insert" | "insertMany">;
2982
+ /**
2983
+ * @description Returns a dry query builder instance
2984
+ * @description The dry query builder instance will not execute the query, it will return the query statement
2985
+ */
2986
+ dryQuery(): Omit<DryModelQueryBuilder<T>, "insert" | "insertMany">;
2884
2987
  /**
2885
2988
  * @description Mysql does not return the inserted model, so we need to get the inserted model from the database
2886
2989
  */
@@ -3004,6 +3107,12 @@ declare class SqlDataSource extends DataSource {
3004
3107
  * @param table The table name to query from, must be in valid sql format `table` or `table as alias`
3005
3108
  */
3006
3109
  static query<S extends string>(table: TableFormat<S>, options?: RawModelOptions): QueryBuilder;
3110
+ /**
3111
+ * @description Returns a dry query builder instance
3112
+ * @description The dry query builder instance will not execute the query, it will return the query statement
3113
+ * @returns The dry query builder instance
3114
+ */
3115
+ static dryQuery<S extends string>(table: TableFormat<S>, options?: RawModelOptions): DryQueryBuilderWithoutReadOperations;
3007
3116
  /**
3008
3117
  * @description Creates a table on the database, return the query to be executed to create the table
3009
3118
  */
@@ -3098,6 +3207,12 @@ declare class SqlDataSource extends DataSource {
3098
3207
  * @param table The table name to query from, must be in valid sql format `table` or `table as alias`
3099
3208
  */
3100
3209
  query<S extends string>(table: TableFormat<S>, options?: RawModelOptions): QueryBuilder;
3210
+ /**
3211
+ * @description Returns a DryQueryBuilder instance
3212
+ * @description The dry query builder instance will not execute the query, it will return the query statement
3213
+ * @returns The dry query builder instance
3214
+ */
3215
+ dryQuery<S extends string>(table: TableFormat<S>, options?: RawModelOptions): DryQueryBuilderWithoutReadOperations;
3101
3216
  /**
3102
3217
  * @description Return the query to alter the given table schema
3103
3218
  */
@@ -3324,6 +3439,47 @@ declare class AstParser {
3324
3439
  private mapCommonDbType;
3325
3440
  }
3326
3441
 
3442
+ declare class DeleteNode extends QueryNode {
3443
+ fromNode: FromNode;
3444
+ chainsWith: string;
3445
+ canKeywordBeSeenMultipleTimes: boolean;
3446
+ folder: string;
3447
+ file: string;
3448
+ constructor(fromNode: FromNode, isRawValue?: boolean);
3449
+ }
3450
+
3451
+ declare class InsertNode extends QueryNode {
3452
+ fromNode: FromNode;
3453
+ records: Record<string, any>[];
3454
+ returning?: string[];
3455
+ disableReturning: boolean;
3456
+ chainsWith: string;
3457
+ canKeywordBeSeenMultipleTimes: boolean;
3458
+ folder: string;
3459
+ file: string;
3460
+ constructor(fromNode: FromNode, records?: Record<string, any>[], returning?: string[], disableReturning?: boolean, isRawValue?: boolean);
3461
+ }
3462
+
3463
+ declare class TruncateNode extends QueryNode {
3464
+ fromNode: FromNode | string;
3465
+ chainsWith: string;
3466
+ canKeywordBeSeenMultipleTimes: boolean;
3467
+ folder: string;
3468
+ file: string;
3469
+ constructor(fromNode: FromNode | string, isRawValue?: boolean);
3470
+ }
3471
+
3472
+ declare class UpdateNode extends QueryNode {
3473
+ fromNode: FromNode;
3474
+ columns: string[];
3475
+ values: (any | RawNode)[];
3476
+ chainsWith: string;
3477
+ canKeywordBeSeenMultipleTimes: boolean;
3478
+ folder: string;
3479
+ file: string;
3480
+ constructor(fromNode: FromNode, columns?: string[], values?: (any | RawNode)[], isRawValue?: boolean);
3481
+ }
3482
+
3327
3483
  declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
3328
3484
  model: typeof Model;
3329
3485
  protected astParser: AstParser;
@@ -3333,6 +3489,10 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
3333
3489
  protected isNestedCondition: boolean;
3334
3490
  protected mustRemoveAnnotations: boolean;
3335
3491
  protected interpreterUtils: InterpreterUtils;
3492
+ protected insertNode: InsertNode | null;
3493
+ protected updateNode: UpdateNode | null;
3494
+ protected deleteNode: DeleteNode | null;
3495
+ protected truncateNode: TruncateNode | null;
3336
3496
  /**
3337
3497
  * @description Performance methods that return the time that took to execute the query with the result
3338
3498
  */
@@ -3434,7 +3594,7 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
3434
3594
  * @postgres needs the pg-query-stream package in order to work
3435
3595
  * @throws If using postgres and the `pg-query-stream` package is not installed
3436
3596
  */
3437
- stream<M extends Model = T>(options?: StreamOptions, cb?: (stream: PassThrough & AsyncGenerator<AnnotatedModel<M, any, any>>) => void | Promise<void>): Promise<PassThrough & AsyncGenerator<AnnotatedModel<M, {}, {}>>>;
3597
+ stream<M extends Model = T>(options?: StreamOptions): Promise<PassThrough & AsyncGenerator<AnnotatedModel<M, {}, {}>>>;
3438
3598
  /**
3439
3599
  * @description Chunks the query into smaller queries, it returns a generator of the chunks
3440
3600
  * @description It will continue to yield chunks until the query returns no results
@@ -3584,6 +3744,22 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
3584
3744
  * @returns raw driver response
3585
3745
  */
3586
3746
  insertMany(data: Record<string, any>[], returning?: string[]): Promise<T[]>;
3747
+ /**
3748
+ * @description Updates or creates a new record using upsert functionality
3749
+ * @param data The data to insert or update
3750
+ * @param searchCriteria The criteria to search for existing records
3751
+ * @param options Upsert options including updateOnConflict and returning columns
3752
+ * @returns The upserted record
3753
+ */
3754
+ upsert<O extends Record<string, any>>(data: O, searchCriteria: Partial<O>, options?: UpsertOptionsRawBuilder): Promise<T[]>;
3755
+ /**
3756
+ * @description Updates or creates multiple records using upsert functionality
3757
+ * @param conflictColumns The columns to check for conflicts
3758
+ * @param columnsToUpdate The columns to update on conflict
3759
+ * @param data Array of data objects to insert or update
3760
+ * @param options Upsert options including updateOnConflict and returning columns
3761
+ */
3762
+ upsertMany<O extends Record<string, any>>(conflictColumns: string[], columnsToUpdate: string[], data: O[], options?: UpsertOptionsRawBuilder): Promise<T[]>;
3587
3763
  /**
3588
3764
  * @description Updates records from a table
3589
3765
  * @returns the number of affected rows
@@ -3609,11 +3785,11 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
3609
3785
  /**
3610
3786
  * @description Returns the query with the parameters bound to the query
3611
3787
  */
3612
- toQuery(dbType?: SqlDataSourceType): string;
3788
+ toQuery(): string;
3613
3789
  /**
3614
3790
  * @description Returns the query with database driver placeholders and the params
3615
3791
  */
3616
- unWrap(_dbType?: SqlDataSourceType): ReturnType<typeof AstParser.prototype.parse>;
3792
+ unWrap(): ReturnType<typeof AstParser.prototype.parse>;
3617
3793
  /**
3618
3794
  * @description Returns a deep clone of the query builder instance.
3619
3795
  */
@@ -3846,6 +4022,11 @@ declare abstract class Model extends Entity {
3846
4022
  * @description Gives a query sqlInstance for the given model
3847
4023
  */
3848
4024
  static query<T extends Model>(this: new () => T | typeof Model, options?: Omit<BaseModelMethodOptions, "ignoreHooks">): ModelQueryBuilder<T>;
4025
+ /**
4026
+ * @description Returns a dry query builder instance
4027
+ * @description The dry query builder instance will not execute the query
4028
+ */
4029
+ static dryQuery<T extends Model>(this: new () => T | typeof Model, options?: Omit<BaseModelMethodOptions, "ignoreHooks">): DryModelQueryBuilderWithoutReadOperations<T>;
3849
4030
  /**
3850
4031
  * @description Finds the first record in the database
3851
4032
  * @deprecated Used only for debugging purposes, use findOne or query instead
@@ -5120,4 +5301,4 @@ declare const generateOpenApiModelWithMetadata: <T extends new () => Model>(mode
5120
5301
  modelName: string;
5121
5302
  }>;
5122
5303
 
5123
- 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 };
5304
+ 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
@@ -1392,6 +1392,63 @@ declare class InterpreterUtils {
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
+ * @returns The query builder
1414
+ */
1415
+ insert(...args: Parameters<typeof QueryBuilder.prototype.insert>): this;
1416
+ /**
1417
+ * @description Builds the insert many query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
1418
+ * @param args The arguments to pass to the insert many method
1419
+ * @returns The query builder
1420
+ */
1421
+ insertMany(...args: Parameters<typeof QueryBuilder.prototype.insertMany>): this;
1422
+ /**
1423
+ * @description Builds the upsert query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
1424
+ * @param args The arguments to pass to the upsert method
1425
+ * @returns The query builder
1426
+ */
1427
+ upsert(...args: Parameters<typeof QueryBuilder.prototype.upsert>): this;
1428
+ /**
1429
+ * @description Builds the update query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
1430
+ * @param data The data to update
1431
+ * @returns The query builder
1432
+ */
1433
+ update(data: Record<string, any>): this;
1434
+ /**
1435
+ * @description Builds the delete query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
1436
+ * @returns The query builder
1437
+ */
1438
+ delete(): this;
1439
+ /**
1440
+ * @description Builds the truncate query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
1441
+ * @returns The query builder
1442
+ */
1443
+ truncate(): this;
1444
+ /**
1445
+ * @description Builds the soft delete query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
1446
+ * @param options Soft delete options
1447
+ * @returns The query builder
1448
+ */
1449
+ softDelete(options?: Omit<SoftDeleteOptions<any>, "ignoreBeforeDeleteHook">): this;
1450
+ }
1451
+
1395
1452
  type BaseValues$1 = string | number | boolean | null;
1396
1453
  type BinaryOperatorType$1 = "=" | "!=" | "<>" | ">" | "<" | ">=" | "<=" | "like" | "ilike" | "in";
1397
1454
  declare class HavingNode extends QueryNode {
@@ -2401,6 +2458,12 @@ type PaginateWithCursorOptions<T extends Model, K extends ModelKey<T>> = {
2401
2458
  operator?: "<" | ">";
2402
2459
  orderBy?: "asc" | "desc";
2403
2460
  };
2461
+ type UpsertOptionsRawBuilder = {
2462
+ updateOnConflict?: boolean;
2463
+ returning?: string[];
2464
+ };
2465
+ type DryQueryBuilderWithoutReadOperations = Omit<DryQueryBuilder, "many" | "one" | "oneOrFail" | "first" | "firstOrFail" | "paginate" | "paginateWithCursor" | "exists" | "pluck" | "upsert" | "upsertMany" | "increment" | "decrement" | "getSum" | "getAvg" | "getMin" | "getMax" | "getCount" | "stream" | "chunk" | "paginate" | "paginateWithCursor" | "exists">;
2466
+ 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">;
2404
2467
 
2405
2468
  declare class SqlModelManagerUtils<T extends Model> {
2406
2469
  protected dbType: SqlDataSourceType;
@@ -2436,15 +2499,6 @@ type CursorPaginatedData<T extends Model, A extends object = {}, R extends objec
2436
2499
  data: AnnotatedModel<T, A, R>[];
2437
2500
  };
2438
2501
 
2439
- type DeleteOptions = {
2440
- ignoreBeforeDeleteHook?: boolean;
2441
- };
2442
- type SoftDeleteOptions<T> = {
2443
- column?: MongoCollectionKey<T>;
2444
- value?: string | number | boolean;
2445
- ignoreBeforeDeleteHook?: boolean;
2446
- };
2447
-
2448
2502
  type UpdateOptions = {
2449
2503
  ignoreBeforeUpdateHook?: boolean;
2450
2504
  };
@@ -2822,6 +2876,50 @@ declare class ModelQueryBuilder<T extends Model, A extends Record<string, any> =
2822
2876
  private truncateWithPerformance;
2823
2877
  }
2824
2878
 
2879
+ /**
2880
+ * Allows to get model queries without executing them
2881
+ */
2882
+ declare class DryModelQueryBuilder<T extends Model, A extends Record<string, any> = {}, R extends Record<string, any> = {}> extends ModelQueryBuilder<T, A, R> {
2883
+ constructor(model: typeof Model, sqlDataSource: SqlDataSource);
2884
+ many(): this;
2885
+ /**
2886
+ * @description Builds the insert query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
2887
+ * @param args The arguments to pass to the insert method
2888
+ * @returns The query builder
2889
+ */
2890
+ insert(...args: Parameters<typeof this$1.model.insert<T>>): this;
2891
+ /**
2892
+ * @description Builds the insert many query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
2893
+ * @param args The arguments to pass to the insert many method
2894
+ * @returns The query builder
2895
+ */
2896
+ insertMany(...args: Parameters<typeof this$1.model.insertMany<T>>): this;
2897
+ /**
2898
+ * @description Builds the update query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
2899
+ * @param data The data to update
2900
+ * @param options Update options
2901
+ * @returns The query builder
2902
+ */
2903
+ update(...args: Parameters<ReturnType<typeof this$1.model.query<T>>["update"]>): this;
2904
+ /**
2905
+ * @description Builds the delete query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
2906
+ * @param options Delete options
2907
+ * @returns The query builder
2908
+ */
2909
+ delete(...args: Parameters<ReturnType<typeof this$1.model.query<T>>["delete"]>): this;
2910
+ /**
2911
+ * @description Builds the truncate query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
2912
+ * @returns The query builder
2913
+ */
2914
+ truncate(): this;
2915
+ /**
2916
+ * @description Builds the soft delete query statement without executing it, use 'unWrap' or 'toQuery' to get the query statement
2917
+ * @param options Soft delete options
2918
+ * @returns The query builder
2919
+ */
2920
+ softDelete(...args: Parameters<ReturnType<typeof this$1.model.query<T>>["softDelete"]>): this;
2921
+ }
2922
+
2825
2923
  declare class ModelManager<T extends Model> {
2826
2924
  protected sqlDataSource: SqlDataSource;
2827
2925
  protected sqlType: SqlDataSourceType;
@@ -2881,6 +2979,11 @@ declare class ModelManager<T extends Model> {
2881
2979
  * @description Returns a query builder instance
2882
2980
  */
2883
2981
  query(): Omit<ModelQueryBuilder<T>, "insert" | "insertMany">;
2982
+ /**
2983
+ * @description Returns a dry query builder instance
2984
+ * @description The dry query builder instance will not execute the query, it will return the query statement
2985
+ */
2986
+ dryQuery(): Omit<DryModelQueryBuilder<T>, "insert" | "insertMany">;
2884
2987
  /**
2885
2988
  * @description Mysql does not return the inserted model, so we need to get the inserted model from the database
2886
2989
  */
@@ -3004,6 +3107,12 @@ declare class SqlDataSource extends DataSource {
3004
3107
  * @param table The table name to query from, must be in valid sql format `table` or `table as alias`
3005
3108
  */
3006
3109
  static query<S extends string>(table: TableFormat<S>, options?: RawModelOptions): QueryBuilder;
3110
+ /**
3111
+ * @description Returns a dry query builder instance
3112
+ * @description The dry query builder instance will not execute the query, it will return the query statement
3113
+ * @returns The dry query builder instance
3114
+ */
3115
+ static dryQuery<S extends string>(table: TableFormat<S>, options?: RawModelOptions): DryQueryBuilderWithoutReadOperations;
3007
3116
  /**
3008
3117
  * @description Creates a table on the database, return the query to be executed to create the table
3009
3118
  */
@@ -3098,6 +3207,12 @@ declare class SqlDataSource extends DataSource {
3098
3207
  * @param table The table name to query from, must be in valid sql format `table` or `table as alias`
3099
3208
  */
3100
3209
  query<S extends string>(table: TableFormat<S>, options?: RawModelOptions): QueryBuilder;
3210
+ /**
3211
+ * @description Returns a DryQueryBuilder instance
3212
+ * @description The dry query builder instance will not execute the query, it will return the query statement
3213
+ * @returns The dry query builder instance
3214
+ */
3215
+ dryQuery<S extends string>(table: TableFormat<S>, options?: RawModelOptions): DryQueryBuilderWithoutReadOperations;
3101
3216
  /**
3102
3217
  * @description Return the query to alter the given table schema
3103
3218
  */
@@ -3324,6 +3439,47 @@ declare class AstParser {
3324
3439
  private mapCommonDbType;
3325
3440
  }
3326
3441
 
3442
+ declare class DeleteNode extends QueryNode {
3443
+ fromNode: FromNode;
3444
+ chainsWith: string;
3445
+ canKeywordBeSeenMultipleTimes: boolean;
3446
+ folder: string;
3447
+ file: string;
3448
+ constructor(fromNode: FromNode, isRawValue?: boolean);
3449
+ }
3450
+
3451
+ declare class InsertNode extends QueryNode {
3452
+ fromNode: FromNode;
3453
+ records: Record<string, any>[];
3454
+ returning?: string[];
3455
+ disableReturning: boolean;
3456
+ chainsWith: string;
3457
+ canKeywordBeSeenMultipleTimes: boolean;
3458
+ folder: string;
3459
+ file: string;
3460
+ constructor(fromNode: FromNode, records?: Record<string, any>[], returning?: string[], disableReturning?: boolean, isRawValue?: boolean);
3461
+ }
3462
+
3463
+ declare class TruncateNode extends QueryNode {
3464
+ fromNode: FromNode | string;
3465
+ chainsWith: string;
3466
+ canKeywordBeSeenMultipleTimes: boolean;
3467
+ folder: string;
3468
+ file: string;
3469
+ constructor(fromNode: FromNode | string, isRawValue?: boolean);
3470
+ }
3471
+
3472
+ declare class UpdateNode extends QueryNode {
3473
+ fromNode: FromNode;
3474
+ columns: string[];
3475
+ values: (any | RawNode)[];
3476
+ chainsWith: string;
3477
+ canKeywordBeSeenMultipleTimes: boolean;
3478
+ folder: string;
3479
+ file: string;
3480
+ constructor(fromNode: FromNode, columns?: string[], values?: (any | RawNode)[], isRawValue?: boolean);
3481
+ }
3482
+
3327
3483
  declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
3328
3484
  model: typeof Model;
3329
3485
  protected astParser: AstParser;
@@ -3333,6 +3489,10 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
3333
3489
  protected isNestedCondition: boolean;
3334
3490
  protected mustRemoveAnnotations: boolean;
3335
3491
  protected interpreterUtils: InterpreterUtils;
3492
+ protected insertNode: InsertNode | null;
3493
+ protected updateNode: UpdateNode | null;
3494
+ protected deleteNode: DeleteNode | null;
3495
+ protected truncateNode: TruncateNode | null;
3336
3496
  /**
3337
3497
  * @description Performance methods that return the time that took to execute the query with the result
3338
3498
  */
@@ -3434,7 +3594,7 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
3434
3594
  * @postgres needs the pg-query-stream package in order to work
3435
3595
  * @throws If using postgres and the `pg-query-stream` package is not installed
3436
3596
  */
3437
- stream<M extends Model = T>(options?: StreamOptions, cb?: (stream: PassThrough & AsyncGenerator<AnnotatedModel<M, any, any>>) => void | Promise<void>): Promise<PassThrough & AsyncGenerator<AnnotatedModel<M, {}, {}>>>;
3597
+ stream<M extends Model = T>(options?: StreamOptions): Promise<PassThrough & AsyncGenerator<AnnotatedModel<M, {}, {}>>>;
3438
3598
  /**
3439
3599
  * @description Chunks the query into smaller queries, it returns a generator of the chunks
3440
3600
  * @description It will continue to yield chunks until the query returns no results
@@ -3584,6 +3744,22 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
3584
3744
  * @returns raw driver response
3585
3745
  */
3586
3746
  insertMany(data: Record<string, any>[], returning?: string[]): Promise<T[]>;
3747
+ /**
3748
+ * @description Updates or creates a new record using upsert functionality
3749
+ * @param data The data to insert or update
3750
+ * @param searchCriteria The criteria to search for existing records
3751
+ * @param options Upsert options including updateOnConflict and returning columns
3752
+ * @returns The upserted record
3753
+ */
3754
+ upsert<O extends Record<string, any>>(data: O, searchCriteria: Partial<O>, options?: UpsertOptionsRawBuilder): Promise<T[]>;
3755
+ /**
3756
+ * @description Updates or creates multiple records using upsert functionality
3757
+ * @param conflictColumns The columns to check for conflicts
3758
+ * @param columnsToUpdate The columns to update on conflict
3759
+ * @param data Array of data objects to insert or update
3760
+ * @param options Upsert options including updateOnConflict and returning columns
3761
+ */
3762
+ upsertMany<O extends Record<string, any>>(conflictColumns: string[], columnsToUpdate: string[], data: O[], options?: UpsertOptionsRawBuilder): Promise<T[]>;
3587
3763
  /**
3588
3764
  * @description Updates records from a table
3589
3765
  * @returns the number of affected rows
@@ -3609,11 +3785,11 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
3609
3785
  /**
3610
3786
  * @description Returns the query with the parameters bound to the query
3611
3787
  */
3612
- toQuery(dbType?: SqlDataSourceType): string;
3788
+ toQuery(): string;
3613
3789
  /**
3614
3790
  * @description Returns the query with database driver placeholders and the params
3615
3791
  */
3616
- unWrap(_dbType?: SqlDataSourceType): ReturnType<typeof AstParser.prototype.parse>;
3792
+ unWrap(): ReturnType<typeof AstParser.prototype.parse>;
3617
3793
  /**
3618
3794
  * @description Returns a deep clone of the query builder instance.
3619
3795
  */
@@ -3846,6 +4022,11 @@ declare abstract class Model extends Entity {
3846
4022
  * @description Gives a query sqlInstance for the given model
3847
4023
  */
3848
4024
  static query<T extends Model>(this: new () => T | typeof Model, options?: Omit<BaseModelMethodOptions, "ignoreHooks">): ModelQueryBuilder<T>;
4025
+ /**
4026
+ * @description Returns a dry query builder instance
4027
+ * @description The dry query builder instance will not execute the query
4028
+ */
4029
+ static dryQuery<T extends Model>(this: new () => T | typeof Model, options?: Omit<BaseModelMethodOptions, "ignoreHooks">): DryModelQueryBuilderWithoutReadOperations<T>;
3849
4030
  /**
3850
4031
  * @description Finds the first record in the database
3851
4032
  * @deprecated Used only for debugging purposes, use findOne or query instead
@@ -5120,4 +5301,4 @@ declare const generateOpenApiModelWithMetadata: <T extends new () => Model>(mode
5120
5301
  modelName: string;
5121
5302
  }>;
5122
5303
 
5123
- 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 };
5304
+ 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 };