hysteria-orm 12.1.0 → 12.2.1

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.ts CHANGED
@@ -710,13 +710,14 @@ declare abstract class QueryNode {
710
710
 
711
711
  declare class RawNode extends QueryNode {
712
712
  rawValue: string;
713
+ bindings?: any[];
713
714
  canKeywordBeSeenMultipleTimes: boolean;
714
715
  chainsWith: string;
715
716
  currParamIndex: number;
716
717
  isRawValue: boolean;
717
718
  folder: string;
718
719
  file: string;
719
- constructor(value: string);
720
+ constructor(value: string, bindings?: any[]);
720
721
  }
721
722
 
722
723
  /**
@@ -726,9 +727,9 @@ type Simplify<T, Strip> = T extends infer U ? {
726
727
  [K in keyof U as K extends Strip ? never : K]: U[K];
727
728
  } : never;
728
729
 
729
- type BaseValues$2 = string | number | boolean | null | SqlFuncNode;
730
- type BinaryOperatorType$2 = "=" | "!=" | "<>" | ">" | "<" | ">=" | "<=" | "like" | "ilike" | "in";
731
- declare class HavingNode extends QueryNode {
730
+ type BaseValues$2 = string | number | boolean | undefined | null | RawNode | SqlFuncNode;
731
+ type BinaryOperatorType$2 = "=" | "!=" | "<>" | ">" | "<" | ">=" | "<=" | "is" | "is not" | "like" | "not like" | "is null" | "is not null" | "ilike" | "in" | "not in" | "between" | "not between" | "regexp" | "not regexp" | "not ilike" | (string & {});
732
+ declare class WhereNode extends QueryNode {
732
733
  column: string;
733
734
  isNegated: boolean;
734
735
  operator: BinaryOperatorType$2;
@@ -740,20 +741,6 @@ declare class HavingNode extends QueryNode {
740
741
  constructor(column: string, chainsWith: "and" | "or", isNegated: boolean | undefined, operator: BinaryOperatorType$2, value: BaseValues$2 | BaseValues$2[], isRawValue?: boolean);
741
742
  }
742
743
 
743
- type BaseValues$1 = string | number | boolean | undefined | null | RawNode | SqlFuncNode;
744
- type BinaryOperatorType$1 = "=" | "!=" | "<>" | ">" | "<" | ">=" | "<=" | "is" | "is not" | "like" | "not like" | "is null" | "is not null" | "ilike" | "in" | "not in" | "between" | "not between" | "regexp" | "not regexp" | "not ilike" | (string & {});
745
- declare class WhereNode extends QueryNode {
746
- column: string;
747
- isNegated: boolean;
748
- operator: BinaryOperatorType$1;
749
- value: BaseValues$1 | BaseValues$1[];
750
- chainsWith: "and" | "or";
751
- canKeywordBeSeenMultipleTimes: boolean;
752
- folder: string;
753
- file: string;
754
- constructor(column: string, chainsWith: "and" | "or", isNegated: boolean | undefined, operator: BinaryOperatorType$1, value: BaseValues$1 | BaseValues$1[], isRawValue?: boolean);
755
- }
756
-
757
744
  type SubqueryOperatorType = "in" | "not in" | "exists" | "not exists" | "between" | "not between" | ">" | "<" | ">=" | "<=" | (string & {});
758
745
  declare class WhereSubqueryNode extends QueryNode {
759
746
  column: string;
@@ -775,6 +762,24 @@ declare class WhereGroupNode extends QueryNode {
775
762
  constructor(nodes: (WhereNode | WhereGroupNode | WhereSubqueryNode)[], chainsWith?: "and" | "or");
776
763
  }
777
764
 
765
+ type BaseValues$1 = string | number | boolean | null | SqlFuncNode;
766
+ type BinaryOperatorType$1 = "=" | "!=" | "<>" | ">" | "<" | ">=" | "<=" | "like" | "ilike" | "is null" | "is not null" | "in" | "not in" | "between" | "not between" | "exists" | "not exists";
767
+ declare class HavingNode extends QueryNode {
768
+ column: string;
769
+ isNegated: boolean;
770
+ operator: BinaryOperatorType$1;
771
+ value: BaseValues$1 | BaseValues$1[] | undefined;
772
+ /** Subquery used by the in/exists operators. */
773
+ subquery?: string | QueryNode | QueryNode[];
774
+ /** Nested HAVING conditions wrapped in parentheses. */
775
+ group?: HavingNode[];
776
+ chainsWith: "and" | "or";
777
+ canKeywordBeSeenMultipleTimes: boolean;
778
+ folder: string;
779
+ file: string;
780
+ constructor(column: string, chainsWith: "and" | "or", isNegated: boolean | undefined, operator: BinaryOperatorType$1, value: BaseValues$1 | BaseValues$1[] | undefined, isRawValue?: boolean, subquery?: string | QueryNode | QueryNode[], group?: HavingNode[]);
781
+ }
782
+
778
783
  type OpenApiModelType = {
779
784
  type: "object";
780
785
  properties: Record<string, OpenApiModelPropertyType>;
@@ -792,31 +797,6 @@ type OpenApiModelPropertyType = {
792
797
  excludeFromSwagger?: boolean;
793
798
  };
794
799
 
795
- declare abstract class DataSource {
796
- type: DataSourceType;
797
- host: string;
798
- port: number;
799
- username: string;
800
- password: string;
801
- database: string;
802
- url: string;
803
- /** @see CommonDataSourceInput.logs — off by default; sync when enabled */
804
- logs: boolean | LoggerConfig;
805
- protected constructor(input?: DataSourceInput);
806
- protected handleCockroachdbSource(input?: PostgresSqlDataSourceInput): void;
807
- protected handlePostgresSource(input?: PostgresSqlDataSourceInput): void;
808
- protected handleMysqlSource(input?: MysqlSqlDataSourceInput): void;
809
- protected handleSqliteSource(input?: SqliteDataSourceInput): void;
810
- protected handleMongoSource(input?: MongoDataSourceInput$1): void;
811
- protected handleMssqlSource(input?: MssqlDataSourceInput): void;
812
- }
813
-
814
- declare abstract class BaseBuilder {
815
- protected nodes: QueryNode[];
816
- constructor(nodes: QueryNode[]);
817
- getNodes(): QueryNode[];
818
- }
819
-
820
800
  declare class ColumnTypeNode extends QueryNode {
821
801
  column: string | (() => string);
822
802
  dataType: string;
@@ -856,6 +836,134 @@ declare class ColumnTypeNode extends QueryNode {
856
836
  });
857
837
  }
858
838
 
839
+ type ConstraintType = "primary_key" | "foreign_key" | "unique" | "not_null" | "null" | "default" | "check";
840
+ declare class ConstraintNode extends QueryNode {
841
+ constraintType: ConstraintType;
842
+ columns?: (string | (() => string))[];
843
+ references?: {
844
+ table: string;
845
+ columns: (string | (() => string))[];
846
+ };
847
+ constraintName?: string;
848
+ onDelete?: "cascade" | "restrict" | "set null" | "no action";
849
+ onUpdate?: "cascade" | "restrict" | "set null" | "no action";
850
+ defaultValue?: string | RawNode | SqlFuncNode | undefined;
851
+ checkExpression?: string;
852
+ chainsWith: string;
853
+ canKeywordBeSeenMultipleTimes: boolean;
854
+ folder: string;
855
+ file: string;
856
+ constructor(constraintType: ConstraintType, args?: {
857
+ columns?: string[];
858
+ references?: {
859
+ table: string;
860
+ columns: string[];
861
+ };
862
+ constraintName?: string;
863
+ onDelete?: "cascade" | "restrict" | "set null" | "no action";
864
+ onUpdate?: "cascade" | "restrict" | "set null" | "no action";
865
+ defaultValue?: string | RawNode | SqlFuncNode | undefined;
866
+ checkExpression?: string;
867
+ }, isRawValue?: boolean);
868
+ }
869
+
870
+ type JsonMutationOperation = "set" | "insert" | "remove";
871
+ /** A JSON path as a `'$.a.b[0]'` JsonPath string or an array of segments. */
872
+ type JsonPath = string | (string | number)[];
873
+ /**
874
+ * @description Expression node that mutates a JSON column at a path. Used as an
875
+ * update value (e.g. `update({ meta: sql.jsonSet("meta", "$.a", 1) })`) and can
876
+ * also be projected. `set` replaces an existing value, `insert` keeps it when
877
+ * present, `remove` deletes it.
878
+ */
879
+ declare class JsonMutationNode extends QueryNode {
880
+ operation: JsonMutationOperation;
881
+ column: string;
882
+ path: JsonPath;
883
+ value?: unknown;
884
+ alias?: string;
885
+ chainsWith: string;
886
+ canKeywordBeSeenMultipleTimes: boolean;
887
+ folder: string;
888
+ file: string;
889
+ constructor(operation: JsonMutationOperation, column: string, path: JsonPath, value?: unknown, alias?: string);
890
+ }
891
+
892
+ type LockType = "for_update" | "for_share" | "for_no_key_update" | "for_key_share";
893
+ declare class LockNode extends QueryNode {
894
+ lockType: LockType;
895
+ skipLocked: boolean;
896
+ noWait: boolean;
897
+ chainsWith: string;
898
+ canKeywordBeSeenMultipleTimes: boolean;
899
+ folder: string;
900
+ file: string;
901
+ constructor(lockType: LockType, skipLocked?: boolean, noWait?: boolean);
902
+ }
903
+
904
+ type WindowDirection = "asc" | "desc";
905
+ interface WindowOrder {
906
+ column: string;
907
+ order?: WindowDirection;
908
+ }
909
+ /** ORDER BY input: a column, a { column, order } object, or an array of either. */
910
+ type WindowOrderInput = string | WindowOrder | (string | WindowOrder)[];
911
+ /** PARTITION BY input: a column or an array of columns. */
912
+ type WindowPartitionInput = string | string[];
913
+ /** Options for `rank`/`denseRank`/`rowNumber`. */
914
+ interface WindowOptions {
915
+ partitionBy?: WindowPartitionInput;
916
+ orderBy?: WindowOrderInput;
917
+ }
918
+
919
+ type SetOperationType = "union" | "intersect" | "except";
920
+ declare class UnionNode extends QueryNode {
921
+ query: QueryNode | QueryNode[] | string;
922
+ isAll: boolean;
923
+ type: SetOperationType;
924
+ chainsWith: string;
925
+ canKeywordBeSeenMultipleTimes: boolean;
926
+ folder: string;
927
+ file: string;
928
+ constructor(query: QueryNode | QueryNode[] | string, isAll?: boolean, type?: SetOperationType);
929
+ }
930
+
931
+ declare class WithNode extends QueryNode {
932
+ alias: string;
933
+ body: QueryNode | QueryNode[];
934
+ clause: string;
935
+ chainsWith: string;
936
+ canKeywordBeSeenMultipleTimes: boolean;
937
+ folder: string;
938
+ file: string;
939
+ constructor(clause: string, alias: string, body: QueryNode | QueryNode[]);
940
+ }
941
+
942
+ declare abstract class DataSource {
943
+ type: DataSourceType;
944
+ host: string;
945
+ port: number;
946
+ username: string;
947
+ password: string;
948
+ database: string;
949
+ url: string;
950
+ /** @see CommonDataSourceInput.logs — off by default; sync when enabled */
951
+ logs: boolean | LoggerConfig;
952
+ protected constructor(input?: DataSourceInput);
953
+ protected handleCockroachdbSource(input?: PostgresSqlDataSourceInput): void;
954
+ protected handlePostgresSource(input?: PostgresSqlDataSourceInput): void;
955
+ protected handleMysqlSource(input?: MysqlSqlDataSourceInput): void;
956
+ protected handleSqliteSource(input?: SqliteDataSourceInput): void;
957
+ protected handleMongoSource(input?: MongoDataSourceInput$1): void;
958
+ protected handleMssqlSource(input?: MssqlDataSourceInput): void;
959
+ }
960
+
961
+ declare abstract class BaseBuilder {
962
+ protected nodes: QueryNode[];
963
+ constructor(nodes: QueryNode[]);
964
+ getNodes(): QueryNode[];
965
+ }
966
+
859
967
  declare class ConstraintBuilder extends BaseBuilder {
860
968
  private readonly columnNode;
861
969
  private readonly tableName?;
@@ -1269,70 +1377,6 @@ declare class CreateTableBuilder extends BaseBuilder {
1269
1377
  getNamedConstraints(): QueryNode[];
1270
1378
  }
1271
1379
 
1272
- type ConstraintType = "primary_key" | "foreign_key" | "unique" | "not_null" | "null" | "default" | "check";
1273
- declare class ConstraintNode extends QueryNode {
1274
- constraintType: ConstraintType;
1275
- columns?: (string | (() => string))[];
1276
- references?: {
1277
- table: string;
1278
- columns: (string | (() => string))[];
1279
- };
1280
- constraintName?: string;
1281
- onDelete?: "cascade" | "restrict" | "set null" | "no action";
1282
- onUpdate?: "cascade" | "restrict" | "set null" | "no action";
1283
- defaultValue?: string | RawNode | SqlFuncNode | undefined;
1284
- checkExpression?: string;
1285
- chainsWith: string;
1286
- canKeywordBeSeenMultipleTimes: boolean;
1287
- folder: string;
1288
- file: string;
1289
- constructor(constraintType: ConstraintType, args?: {
1290
- columns?: string[];
1291
- references?: {
1292
- table: string;
1293
- columns: string[];
1294
- };
1295
- constraintName?: string;
1296
- onDelete?: "cascade" | "restrict" | "set null" | "no action";
1297
- onUpdate?: "cascade" | "restrict" | "set null" | "no action";
1298
- defaultValue?: string | RawNode | SqlFuncNode | undefined;
1299
- checkExpression?: string;
1300
- }, isRawValue?: boolean);
1301
- }
1302
-
1303
- type LockType = "for_update" | "for_share" | "for_no_key_update" | "for_key_share";
1304
- declare class LockNode extends QueryNode {
1305
- lockType: LockType;
1306
- skipLocked: boolean;
1307
- noWait: boolean;
1308
- chainsWith: string;
1309
- canKeywordBeSeenMultipleTimes: boolean;
1310
- folder: string;
1311
- file: string;
1312
- constructor(lockType: LockType, skipLocked?: boolean, noWait?: boolean);
1313
- }
1314
-
1315
- declare class UnionNode extends QueryNode {
1316
- query: QueryNode | QueryNode[] | string;
1317
- isAll: boolean;
1318
- chainsWith: string;
1319
- canKeywordBeSeenMultipleTimes: boolean;
1320
- folder: string;
1321
- file: string;
1322
- constructor(query: QueryNode | QueryNode[] | string, isAll?: boolean);
1323
- }
1324
-
1325
- declare class WithNode extends QueryNode {
1326
- alias: string;
1327
- body: QueryNode | QueryNode[];
1328
- clause: string;
1329
- chainsWith: string;
1330
- canKeywordBeSeenMultipleTimes: boolean;
1331
- folder: string;
1332
- file: string;
1333
- constructor(clause: string, alias: string, body: QueryNode | QueryNode[]);
1334
- }
1335
-
1336
1380
  declare class AlterTableBuilder extends BaseBuilder {
1337
1381
  private table;
1338
1382
  private sqlType;
@@ -1785,6 +1829,8 @@ declare class FromNode extends QueryNode {
1785
1829
  folder: string;
1786
1830
  file: string;
1787
1831
  alias?: string;
1832
+ /** Schema applied to the table reference (e.g. `public.users`). */
1833
+ schema?: string;
1788
1834
  constructor(table: string | QueryNode | QueryNode[], alias?: string);
1789
1835
  }
1790
1836
 
@@ -1862,6 +1908,18 @@ declare class InterpreterUtils {
1862
1908
  * @description Formats the table name for the database type, idempotent for quoting
1863
1909
  */
1864
1910
  formatStringTable(dbType: SqlDataSourceType, table: string): string;
1911
+ /**
1912
+ * @description Quotes a single identifier for the given dialect.
1913
+ */
1914
+ quoteIdentifier(dbType: SqlDataSourceType, name: string): string;
1915
+ /**
1916
+ * @description Rewrites `?` placeholders in a raw SQL fragment to the dialect's
1917
+ * placeholder starting at `startIndex`, returning the fragment and its bindings.
1918
+ */
1919
+ formatRawPlaceholders(dbType: SqlDataSourceType, raw: string, bindings?: any[], startIndex?: number): {
1920
+ sql: string;
1921
+ bindings: any[];
1922
+ };
1865
1923
  prepareColumns(columns: string[], values: any[], mode?: "insert" | "update", dbType?: SqlDataSourceType): {
1866
1924
  columns: string[];
1867
1925
  values: any[];
@@ -2189,6 +2247,49 @@ declare class DeleteNode extends QueryNode {
2189
2247
  constructor(fromNode: FromNode, isRawValue?: boolean);
2190
2248
  }
2191
2249
 
2250
+ type TableColumnInfo = {
2251
+ name: string;
2252
+ dataType: string;
2253
+ isNullable: boolean;
2254
+ defaultValue: string | number | boolean | null;
2255
+ length?: number | null;
2256
+ precision?: number | null;
2257
+ scale?: number | null;
2258
+ withTimezone?: boolean | null;
2259
+ enumValues?: string[] | null;
2260
+ unsigned?: boolean | null;
2261
+ zerofill?: boolean | null;
2262
+ stringMode?: boolean | null;
2263
+ };
2264
+ type TableIndexInfo = {
2265
+ name: string;
2266
+ columns: string[];
2267
+ isUnique: boolean;
2268
+ };
2269
+ type TablePrimaryKeyInfo = {
2270
+ name?: string;
2271
+ columns: string[];
2272
+ };
2273
+ type TableCheckConstraintInfo = {
2274
+ name: string;
2275
+ expression: string;
2276
+ };
2277
+ type TableSchemaInfo = {
2278
+ columns: TableColumnInfo[];
2279
+ indexes: TableIndexInfo[];
2280
+ foreignKeys: TableForeignKeyInfo[];
2281
+ primaryKey?: TablePrimaryKeyInfo;
2282
+ checkConstraints: TableCheckConstraintInfo[];
2283
+ };
2284
+ type TableForeignKeyInfo = {
2285
+ name?: string;
2286
+ columns: string[];
2287
+ referencedTable: string;
2288
+ referencedColumns: string[];
2289
+ onDelete?: string | null;
2290
+ onUpdate?: string | null;
2291
+ };
2292
+
2192
2293
  declare class InsertNode extends QueryNode {
2193
2294
  fromNode: FromNode;
2194
2295
  records: Record<string, any>[];
@@ -2824,6 +2925,11 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
2824
2925
  protected returningNode: ReturningNode | null;
2825
2926
  protected truncateNode: TruncateNode | null;
2826
2927
  protected replicationMode: ReplicationType | null;
2928
+ protected schemaName?: string;
2929
+ protected queryTimeout?: {
2930
+ ms: number;
2931
+ cancel: boolean;
2932
+ };
2827
2933
  constructor(model: typeof Model, sqlDataSource: SqlDataSource);
2828
2934
  /**
2829
2935
  * @description Sets the replication mode for the query builder
@@ -2899,6 +3005,24 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
2899
3005
  selectJsonRaw<ValueType = any, Alias extends string = string>(raw: string, alias: Alias): QueryBuilder<T, ComposeRawSelect<S, {
2900
3006
  [K in Alias]: ValueType;
2901
3007
  }>, D>;
3008
+ countDistinct<Alias extends string = string>(column: string, alias: Alias): QueryBuilder<T, ComposeRawSelect<S, {
3009
+ [K in Alias]: number;
3010
+ }>, D>;
3011
+ sumDistinct<Alias extends string = string>(column: string, alias: Alias): QueryBuilder<T, ComposeRawSelect<S, {
3012
+ [K in Alias]: number;
3013
+ }>, D>;
3014
+ avgDistinct<Alias extends string = string>(column: string, alias: Alias): QueryBuilder<T, ComposeRawSelect<S, {
3015
+ [K in Alias]: number;
3016
+ }>, D>;
3017
+ rank<Alias extends string = never>(alias?: Alias, options?: WindowOptions): QueryBuilder<T, ComposeRawSelect<S, {
3018
+ [K in Alias]: number;
3019
+ }>, D>;
3020
+ denseRank<Alias extends string = never>(alias?: Alias, options?: WindowOptions): QueryBuilder<T, ComposeRawSelect<S, {
3021
+ [K in Alias]: number;
3022
+ }>, D>;
3023
+ rowNumber<Alias extends string = never>(alias?: Alias, options?: WindowOptions): QueryBuilder<T, ComposeRawSelect<S, {
3024
+ [K in Alias]: number;
3025
+ }>, D>;
2902
3026
  /**
2903
3027
  * @description Executes the query and returns true if the query returns at least one result, false otherwise.
2904
3028
  */
@@ -2987,6 +3111,38 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
2987
3111
  skipLocked?: boolean;
2988
3112
  noWait?: boolean;
2989
3113
  }): this;
3114
+ /**
3115
+ * @description Locks the selected rows with the `FOR NO KEY UPDATE` strength.
3116
+ * Weaker than `FOR UPDATE`: it does not block foreign keys that reference the row.
3117
+ * @postgres only
3118
+ * @throws HysteriaError if the database type is not postgres
3119
+ */
3120
+ forNoKeyUpdate(options?: {
3121
+ skipLocked?: boolean;
3122
+ noWait?: boolean;
3123
+ }): this;
3124
+ /**
3125
+ * @description Locks the selected rows with the `FOR KEY SHARE` strength.
3126
+ * The weakest row lock: only blocks updates that change a key value.
3127
+ * @postgres only
3128
+ * @throws HysteriaError if the database type is not postgres
3129
+ */
3130
+ forKeyShare(options?: {
3131
+ skipLocked?: boolean;
3132
+ noWait?: boolean;
3133
+ }): this;
3134
+ private assertPgLockStrength;
3135
+ /**
3136
+ * @description Sets a wall-clock timeout for this query. When exceeded the
3137
+ * query rejects with a `QUERY_TIMEOUT` HysteriaError.
3138
+ * @param ms - Maximum execution time in milliseconds
3139
+ * @param options.cancel - When true, ask the driver to cancel the running
3140
+ * query. Honored by PostgreSQL and MySQL/MariaDB; MSSQL cancels its request;
3141
+ * SQLite and Bun have no cancellation and only enforce the timeout.
3142
+ */
3143
+ timeout(ms: number, options?: {
3144
+ cancel?: boolean;
3145
+ }): this;
2990
3146
  /**
2991
3147
  * @description Prepends a native SQL comment to the select statement, in the
2992
3148
  * syntax of the active dialect (e.g. `-- line`, `/* block *\/`; MySQL adds
@@ -3029,6 +3185,17 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3029
3185
  unionAll(query: string, bindings?: any[]): this;
3030
3186
  unionAll(cb: UnionCallBack<T>): this;
3031
3187
  unionAll(queryBuilder: QueryBuilder<any>): this;
3188
+ /**
3189
+ * @description Adds an INTERSECT to the query (keeps only rows present in both queries).
3190
+ */
3191
+ intersect(query: string): this;
3192
+ intersect(cb: UnionCallBack<T>): this;
3193
+ /**
3194
+ * @description Adds an EXCEPT to the query (keeps rows from the first query not present in the second).
3195
+ */
3196
+ except(query: string): this;
3197
+ except(cb: UnionCallBack<T>): this;
3198
+ private resolveSetOperationNodes;
3032
3199
  /**
3033
3200
  * @description Increments the value of a column by a given amount
3034
3201
  * @typeSafe - In typescript, only numeric columns of the model will be accepted if using a Model
@@ -3079,6 +3246,12 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3079
3246
  * @description Executes the query and retrieves the sum of a column, it ignores all select, group by, order by, limit and offset clauses if they are present.
3080
3247
  */
3081
3248
  getSum(column: string): Promise<number>;
3249
+ /**
3250
+ * @description Introspects column metadata for the query's table. With a
3251
+ * column name it returns that column's info, otherwise every column.
3252
+ */
3253
+ columnInfo(): Promise<TableColumnInfo[]>;
3254
+ columnInfo(column: string): Promise<TableColumnInfo | undefined>;
3082
3255
  /**
3083
3256
  * @description Executes the query and retrieves multiple paginated results.
3084
3257
  * @description Overrides the limit and offset clauses in order to paginate the results.
@@ -3090,6 +3263,16 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3090
3263
  */
3091
3264
  table<S extends string>(table: TableFormat<S>, maybeAlias?: string): this;
3092
3265
  table<S extends string>(cb: (qb: QueryBuilder<T>) => void | SubQueryable, alias: string): this;
3266
+ /**
3267
+ * @description Sets the schema (search path) applied to every table reference in
3268
+ * this query, rendering two-part names such as `schema.table`.
3269
+ */
3270
+ withSchema(schemaName: string): this;
3271
+ /**
3272
+ * @description Uses a raw SQL fragment as the FROM source. `?` placeholders are
3273
+ * rewritten to the dialect's placeholders, in order with the rest of the query.
3274
+ */
3275
+ fromRaw(raw: string, bindings?: any[]): this;
3093
3276
  /**
3094
3277
  * @description Adds a CTE to the query using a callback to build the subquery.
3095
3278
  */
@@ -3105,6 +3288,12 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3105
3288
  * @throws HysteriaError if the database type is not postgres or cockroachdb
3106
3289
  */
3107
3290
  withMaterialized(alias: string, cb: (qb: QueryBuilder<T>) => void | SubQueryable): this;
3291
+ /**
3292
+ * @description Adds a non-materialized CTE to the query using a callback to build the subquery.
3293
+ * @postgres only
3294
+ * @throws HysteriaError if the database type is not postgres or cockroachdb
3295
+ */
3296
+ withNotMaterialized(alias: string, cb: (qb: QueryBuilder<T>) => void | SubQueryable): this;
3108
3297
  /**
3109
3298
  * @description Insert record into a table, you can use raw statements in the data object for literal references to other columns
3110
3299
  * @param returning - The columns to return from the query, only supported by postgres and cockroachdb - default is "*"
@@ -3238,49 +3427,6 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3238
3427
  protected execSqlWithSlaveHandling<R>(mode: "read" | "write", operation: (dataSource: SqlDataSource) => Promise<R>): Promise<R>;
3239
3428
  }
3240
3429
 
3241
- type TableColumnInfo = {
3242
- name: string;
3243
- dataType: string;
3244
- isNullable: boolean;
3245
- defaultValue: string | number | boolean | null;
3246
- length?: number | null;
3247
- precision?: number | null;
3248
- scale?: number | null;
3249
- withTimezone?: boolean | null;
3250
- enumValues?: string[] | null;
3251
- unsigned?: boolean | null;
3252
- zerofill?: boolean | null;
3253
- stringMode?: boolean | null;
3254
- };
3255
- type TableIndexInfo = {
3256
- name: string;
3257
- columns: string[];
3258
- isUnique: boolean;
3259
- };
3260
- type TablePrimaryKeyInfo = {
3261
- name?: string;
3262
- columns: string[];
3263
- };
3264
- type TableCheckConstraintInfo = {
3265
- name: string;
3266
- expression: string;
3267
- };
3268
- type TableSchemaInfo = {
3269
- columns: TableColumnInfo[];
3270
- indexes: TableIndexInfo[];
3271
- foreignKeys: TableForeignKeyInfo[];
3272
- primaryKey?: TablePrimaryKeyInfo;
3273
- checkConstraints: TableCheckConstraintInfo[];
3274
- };
3275
- type TableForeignKeyInfo = {
3276
- name?: string;
3277
- columns: string[];
3278
- referencedTable: string;
3279
- referencedColumns: string[];
3280
- onDelete?: string | null;
3281
- onUpdate?: string | null;
3282
- };
3283
-
3284
3430
  type Returning = "rows" | "affectedRows" | "raw";
3285
3431
  /**
3286
3432
  * @description Maps a SqlDataSourceType to the raw driver response type
@@ -3637,6 +3783,11 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
3637
3783
  * ```
3638
3784
  */
3639
3785
  from<S extends string>(table: TableFormat<S>, options?: RawModelOptions): QueryBuilder<any, Record<string, any>, D>;
3786
+ /**
3787
+ * @description Starts a query from a raw SQL fragment, e.g. a table-valued
3788
+ * function or a derived table. `?` placeholders are rewritten per dialect.
3789
+ */
3790
+ fromRaw(raw: string, bindings?: any[], options?: RawModelOptions): QueryBuilder<any, Record<string, any>, D>;
3640
3791
  /**
3641
3792
  * @description Returns a SchemaBuilder instance for DDL operations
3642
3793
  * @description The builder will execute queries when awaited or when .execute() is called
@@ -3751,6 +3902,20 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
3751
3902
  * ```
3752
3903
  */
3753
3904
  rawStatement(value: string): RawNode;
3905
+ /**
3906
+ * @description Sets a value at a JSON path, replacing any existing value.
3907
+ * Use as an update value: `update({ meta: sql.jsonSet("meta", "$.a", 1) })`.
3908
+ */
3909
+ jsonSet(column: string, path: JsonPath, value: unknown, alias?: string): JsonMutationNode;
3910
+ /**
3911
+ * @description Inserts a value at a JSON path only when the path is absent.
3912
+ * Use as an update value.
3913
+ */
3914
+ jsonInsert(column: string, path: JsonPath, value: unknown, alias?: string): JsonMutationNode;
3915
+ /**
3916
+ * @description Removes the value at a JSON path. Use as an update value.
3917
+ */
3918
+ jsonRemove(column: string, path: JsonPath, alias?: string): JsonMutationNode;
3754
3919
  /**
3755
3920
  * @description Retrieves information from the database for the given table
3756
3921
  */
@@ -3937,11 +4102,13 @@ declare class SelectNode extends QueryNode {
3937
4102
  column: string | QueryNode | QueryNode[];
3938
4103
  alias?: string;
3939
4104
  sqlFunction?: string;
4105
+ /** Renders the aggregate as `fn(DISTINCT col)` (e.g. count/sum/avg). */
4106
+ distinct?: boolean;
3940
4107
  chainsWith: string;
3941
4108
  canKeywordBeSeenMultipleTimes: boolean;
3942
4109
  folder: string;
3943
4110
  file: string;
3944
- constructor(column: string | QueryNode | QueryNode[], alias?: string, sqlFunction?: string, isRaw?: boolean);
4111
+ constructor(column: string | QueryNode | QueryNode[], alias?: string, sqlFunction?: string, isRaw?: boolean, distinct?: boolean);
3945
4112
  }
3946
4113
 
3947
4114
  declare class JoinNode extends QueryNode {
@@ -3959,6 +4126,10 @@ declare class JoinNode extends QueryNode {
3959
4126
  file: string;
3960
4127
  type: "inner" | "left" | "right" | "full" | "cross" | "natural";
3961
4128
  additionalConditions?: (WhereNode | WhereGroupNode | WhereSubqueryNode)[];
4129
+ /** When set, renders `using (cols)` instead of an `on` condition. */
4130
+ using?: string[];
4131
+ /** Schema applied to the joined table reference. */
4132
+ schema?: string;
3962
4133
  constructor(table: string, left: string, right: string, type: "inner" | "left" | "right" | "full" | "cross" | "natural" | undefined, on: {
3963
4134
  left?: string;
3964
4135
  right?: string;
@@ -4377,60 +4548,60 @@ declare class JoinOnQueryBuilder {
4377
4548
  /**
4378
4549
  * @description Adds a WHERE condition to the query.
4379
4550
  */
4380
- where(column: SelectableColumn$1<string>, operator: BinaryOperatorType$1, value: BaseValues$1): this;
4551
+ where(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
4381
4552
  where(cb: (queryBuilder: JoinOnQueryBuilder) => void): this;
4382
- where(column: SelectableColumn$1<string>, value: BaseValues$1): this;
4553
+ where(column: SelectableColumn$1<string>, value: BaseValues$2): this;
4383
4554
  /**
4384
4555
  * @description Adds an AND WHERE condition to the query.
4385
4556
  */
4386
- andWhere(column: SelectableColumn$1<string>, operator: BinaryOperatorType$1, value: BaseValues$1): this;
4387
- andWhere(column: SelectableColumn$1<string>, value: BaseValues$1): this;
4557
+ andWhere(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
4558
+ andWhere(column: SelectableColumn$1<string>, value: BaseValues$2): this;
4388
4559
  andWhere(cb: (queryBuilder: JoinOnQueryBuilder) => void): this;
4389
4560
  /**
4390
4561
  * @description Adds an OR WHERE condition to the query.
4391
4562
  */
4392
- orWhere(column: SelectableColumn$1<string>, operator: BinaryOperatorType$1, value: BaseValues$1): this;
4393
- orWhere(column: SelectableColumn$1<string>, value: BaseValues$1): this;
4563
+ orWhere(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
4564
+ orWhere(column: SelectableColumn$1<string>, value: BaseValues$2): this;
4394
4565
  orWhere(cb: (queryBuilder: JoinOnQueryBuilder) => void): this;
4395
4566
  /**
4396
4567
  * @description Adds a negated WHERE condition to the query.
4397
4568
  */
4398
- whereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$1, value: BaseValues$1): this;
4399
- whereNot(column: SelectableColumn$1<string>, value: BaseValues$1): this;
4569
+ whereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
4570
+ whereNot(column: SelectableColumn$1<string>, value: BaseValues$2): this;
4400
4571
  /**
4401
4572
  * @description Adds a negated AND WHERE condition to the query.
4402
4573
  */
4403
- andWhereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$1, value: BaseValues$1): this;
4404
- andWhereNot(column: SelectableColumn$1<string>, value: BaseValues$1): this;
4574
+ andWhereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
4575
+ andWhereNot(column: SelectableColumn$1<string>, value: BaseValues$2): this;
4405
4576
  /**
4406
4577
  * @description Adds a negated OR WHERE condition to the query.
4407
4578
  */
4408
- orWhereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$1, value: BaseValues$1): this;
4409
- orWhereNot(column: SelectableColumn$1<string>, value: BaseValues$1): this;
4579
+ orWhereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
4580
+ orWhereNot(column: SelectableColumn$1<string>, value: BaseValues$2): this;
4410
4581
  /**
4411
4582
  * @description Adds a WHERE BETWEEN condition to the query.
4412
4583
  */
4413
- whereBetween(column: SelectableColumn$1<string>, min: BaseValues$1, max: BaseValues$1): this;
4584
+ whereBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
4414
4585
  /**
4415
4586
  * @description Adds an AND WHERE BETWEEN condition to the query.
4416
4587
  */
4417
- andWhereBetween(column: SelectableColumn$1<string>, min: BaseValues$1, max: BaseValues$1): this;
4588
+ andWhereBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
4418
4589
  /**
4419
4590
  * @description Adds an OR WHERE BETWEEN condition to the query.
4420
4591
  */
4421
- orWhereBetween(column: SelectableColumn$1<string>, min: BaseValues$1, max: BaseValues$1): this;
4592
+ orWhereBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
4422
4593
  /**
4423
4594
  * @description Adds a WHERE NOT BETWEEN condition to the query.
4424
4595
  */
4425
- whereNotBetween(column: SelectableColumn$1<string>, min: BaseValues$1, max: BaseValues$1): this;
4596
+ whereNotBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
4426
4597
  /**
4427
4598
  * @description Adds an AND WHERE NOT BETWEEN condition to the query.
4428
4599
  */
4429
- andWhereNotBetween(column: SelectableColumn$1<string>, min: BaseValues$1, max: BaseValues$1): this;
4600
+ andWhereNotBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
4430
4601
  /**
4431
4602
  * @description Adds an OR WHERE NOT BETWEEN condition to the query.
4432
4603
  */
4433
- orWhereNotBetween(column: SelectableColumn$1<string>, min: BaseValues$1, max: BaseValues$1): this;
4604
+ orWhereNotBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
4434
4605
  /**
4435
4606
  * @description Adds a WHERE LIKE condition to the query.
4436
4607
  */
@@ -4482,27 +4653,27 @@ declare class JoinOnQueryBuilder {
4482
4653
  /**
4483
4654
  * @description Adds a WHERE IN condition to the query.
4484
4655
  */
4485
- whereIn(column: SelectableColumn$1<string>, values: BaseValues$1[]): this;
4656
+ whereIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
4486
4657
  /**
4487
4658
  * @description Adds an AND WHERE IN condition to the query.
4488
4659
  */
4489
- andWhereIn(column: SelectableColumn$1<string>, values: BaseValues$1[]): this;
4660
+ andWhereIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
4490
4661
  /**
4491
4662
  * @description Adds an OR WHERE IN condition to the query.
4492
4663
  */
4493
- orWhereIn(column: SelectableColumn$1<string>, values: BaseValues$1[]): this;
4664
+ orWhereIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
4494
4665
  /**
4495
4666
  * @description Adds a WHERE NOT IN condition to the query.
4496
4667
  */
4497
- whereNotIn(column: SelectableColumn$1<string>, values: BaseValues$1[]): this;
4668
+ whereNotIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
4498
4669
  /**
4499
4670
  * @description Adds an AND WHERE NOT IN condition to the query.
4500
4671
  */
4501
- andWhereNotIn(column: SelectableColumn$1<string>, values: BaseValues$1[]): this;
4672
+ andWhereNotIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
4502
4673
  /**
4503
4674
  * @description Adds an OR WHERE NOT IN condition to the query.
4504
4675
  */
4505
- orWhereNotIn(column: SelectableColumn$1<string>, values: BaseValues$1[]): this;
4676
+ orWhereNotIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
4506
4677
  /**
4507
4678
  * @description Adds a WHERE NULL condition to the query.
4508
4679
  */
@@ -4566,15 +4737,15 @@ declare class JoinOnQueryBuilder {
4566
4737
  /**
4567
4738
  * @description Adds a raw WHERE condition to the query.
4568
4739
  */
4569
- whereRaw(sql: string, bindings?: BaseValues$1[]): this;
4740
+ whereRaw(sql: string, bindings?: BaseValues$2[]): this;
4570
4741
  /**
4571
4742
  * @description Adds an AND raw WHERE condition to the query.
4572
4743
  */
4573
- andWhereRaw(sql: string, bindings?: BaseValues$1[]): this;
4744
+ andWhereRaw(sql: string, bindings?: BaseValues$2[]): this;
4574
4745
  /**
4575
4746
  * @description Adds an OR raw WHERE condition to the query.
4576
4747
  */
4577
- orWhereRaw(sql: string, bindings?: BaseValues$1[]): this;
4748
+ orWhereRaw(sql: string, bindings?: BaseValues$2[]): this;
4578
4749
  }
4579
4750
 
4580
4751
  /**
@@ -4608,6 +4779,17 @@ declare abstract class JoinQueryBuilder<T extends Model, S extends Record<string
4608
4779
  * @description Join a table with the current model, join clause is not necessary and will be added automatically
4609
4780
  */
4610
4781
  crossJoinRaw(query: string): this;
4782
+ /**
4783
+ * @description Performs a CROSS JOIN against a table (non-raw).
4784
+ */
4785
+ crossJoin(relationTable: string, alias?: string): this;
4786
+ crossJoin<R extends AnyModelConstructor>(relationModel: R): this;
4787
+ /**
4788
+ * @description Replaces the ON condition of the most recently added join with a
4789
+ * `USING (columns)` clause, e.g. `join("orders").using("user_id")`.
4790
+ * @postgres/mysql/mariadb/cockroachdb/sqlite only
4791
+ */
4792
+ using(...columns: (JoinableColumn | ModelKey<T>)[]): this;
4611
4793
  /**
4612
4794
  * @description Join a table with the current model, join clause is not necessary and will be added automatically
4613
4795
  */
@@ -4619,13 +4801,14 @@ declare abstract class JoinQueryBuilder<T extends Model, S extends Record<string
4619
4801
  * @param primaryColumn - The primary column of the current model, default is caller model primary key if using a Model, if using a Raw Query Builder you must provide the key for the primary table, must be in the format of `table.column`
4620
4802
  * @param operator - The comparison operator to use in the ON clause (default: "=")
4621
4803
  */
4622
- innerJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$1): this;
4623
- innerJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$1): this;
4624
- innerJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator?: BinaryOperatorType$1): this;
4625
- innerJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn?: ModelKey<T>, operator?: BinaryOperatorType$1): this;
4626
- innerJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator: BinaryOperatorType$1, callback: JoinOnCallback): this;
4804
+ innerJoin(relationTable: string): this;
4805
+ innerJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$2): this;
4806
+ innerJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$2): this;
4807
+ innerJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator?: BinaryOperatorType$2): this;
4808
+ innerJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn?: ModelKey<T>, operator?: BinaryOperatorType$2): this;
4809
+ innerJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator: BinaryOperatorType$2, callback: JoinOnCallback): this;
4627
4810
  innerJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, callback: JoinOnCallback): this;
4628
- innerJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator: BinaryOperatorType$1, callback: JoinOnCallback): this;
4811
+ innerJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator: BinaryOperatorType$2, callback: JoinOnCallback): this;
4629
4812
  innerJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, callback: JoinOnCallback): this;
4630
4813
  /**
4631
4814
  * @description Join a table with the current model
@@ -4634,13 +4817,14 @@ declare abstract class JoinQueryBuilder<T extends Model, S extends Record<string
4634
4817
  * @param primaryColumn - The primary column of the current model, default is caller model primary key if using a Model, if using a Raw Query Builder you must provide the key for the primary table, must be in the format of `table.column`
4635
4818
  * @param operator - The comparison operator to use in the ON clause (default: "=")
4636
4819
  */
4637
- join(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$1): this;
4638
- join(relationTable: string, referencingColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$1): this;
4639
- join<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator?: BinaryOperatorType$1): this;
4640
- join<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn?: ModelKey<T>, operator?: BinaryOperatorType$1): this;
4641
- join(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator: BinaryOperatorType$1, callback: JoinOnCallback): this;
4820
+ join(relationTable: string): this;
4821
+ join(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$2): this;
4822
+ join(relationTable: string, referencingColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$2): this;
4823
+ join<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator?: BinaryOperatorType$2): this;
4824
+ join<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn?: ModelKey<T>, operator?: BinaryOperatorType$2): this;
4825
+ join(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator: BinaryOperatorType$2, callback: JoinOnCallback): this;
4642
4826
  join(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, callback: JoinOnCallback): this;
4643
- join<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator: BinaryOperatorType$1, callback: JoinOnCallback): this;
4827
+ join<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator: BinaryOperatorType$2, callback: JoinOnCallback): this;
4644
4828
  join<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, callback: JoinOnCallback): this;
4645
4829
  /**
4646
4830
  * @description Join a table with the current model
@@ -4649,13 +4833,14 @@ declare abstract class JoinQueryBuilder<T extends Model, S extends Record<string
4649
4833
  * @param primaryColumn - The primary column of the current model, default is caller model primary key if using a Model, if using a Raw Query Builder you must provide the key for the primary table, must be in the format of `table.column`
4650
4834
  * @param operator - The comparison operator to use in the ON clause (default: "=")
4651
4835
  */
4652
- leftJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$1): this;
4653
- leftJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$1): this;
4654
- leftJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator?: BinaryOperatorType$1): this;
4655
- leftJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn?: ModelKey<T>, operator?: BinaryOperatorType$1): this;
4656
- leftJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator: BinaryOperatorType$1, callback: JoinOnCallback): this;
4836
+ leftJoin(relationTable: string): this;
4837
+ leftJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$2): this;
4838
+ leftJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$2): this;
4839
+ leftJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator?: BinaryOperatorType$2): this;
4840
+ leftJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn?: ModelKey<T>, operator?: BinaryOperatorType$2): this;
4841
+ leftJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator: BinaryOperatorType$2, callback: JoinOnCallback): this;
4657
4842
  leftJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, callback: JoinOnCallback): this;
4658
- leftJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator: BinaryOperatorType$1, callback: JoinOnCallback): this;
4843
+ leftJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator: BinaryOperatorType$2, callback: JoinOnCallback): this;
4659
4844
  leftJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, callback: JoinOnCallback): this;
4660
4845
  /**
4661
4846
  * @description Join a table with the current model
@@ -4664,10 +4849,11 @@ declare abstract class JoinQueryBuilder<T extends Model, S extends Record<string
4664
4849
  * @param primaryColumn - The primary column of the current model, default is caller model primary key if using A Model, if using a Raw Query Builder you must provide the key for the primary table
4665
4850
  * @param operator - The comparison operator to use in the ON clause (default: "=")
4666
4851
  */
4667
- rightJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$1): this;
4668
- rightJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$1): this;
4669
- rightJoin<R extends AnyModelConstructor>(relationTable: string | R, referencingColumnOrPrimaryColumn: ModelKey<InstanceType<R>> | JoinableColumn | ModelKey<T>, primaryColumn?: JoinableColumn | ModelKey<T>, operator?: BinaryOperatorType$1): this;
4670
- rightJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, operator: BinaryOperatorType$1, callback: JoinOnCallback): this;
4852
+ rightJoin(relationTable: string): this;
4853
+ rightJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$2): this;
4854
+ rightJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$2): this;
4855
+ rightJoin<R extends AnyModelConstructor>(relationTable: string | R, referencingColumnOrPrimaryColumn: ModelKey<InstanceType<R>> | JoinableColumn | ModelKey<T>, primaryColumn?: JoinableColumn | ModelKey<T>, operator?: BinaryOperatorType$2): this;
4856
+ rightJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, operator: BinaryOperatorType$2, callback: JoinOnCallback): this;
4671
4857
  rightJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, callback: JoinOnCallback): this;
4672
4858
  /**
4673
4859
  * @description Perform a FULL OUTER JOIN with another table
@@ -4676,10 +4862,10 @@ declare abstract class JoinQueryBuilder<T extends Model, S extends Record<string
4676
4862
  * @param primaryColumn - The primary column of the current model
4677
4863
  * @param operator - The comparison operator to use in the ON clause (default: "=")
4678
4864
  */
4679
- fullJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$1): this;
4680
- fullJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$1): this;
4681
- fullJoin<R extends AnyModelConstructor>(relationTable: string | R, referencingColumnOrPrimaryColumn: ModelKey<InstanceType<R>> | JoinableColumn | ModelKey<T>, primaryColumn?: JoinableColumn | ModelKey<T>, operator?: BinaryOperatorType$1): this;
4682
- fullJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, operator: BinaryOperatorType$1, callback: JoinOnCallback): this;
4865
+ fullJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$2): this;
4866
+ fullJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$2): this;
4867
+ fullJoin<R extends AnyModelConstructor>(relationTable: string | R, referencingColumnOrPrimaryColumn: ModelKey<InstanceType<R>> | JoinableColumn | ModelKey<T>, primaryColumn?: JoinableColumn | ModelKey<T>, operator?: BinaryOperatorType$2): this;
4868
+ fullJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, operator: BinaryOperatorType$2, callback: JoinOnCallback): this;
4683
4869
  fullJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, callback: JoinOnCallback): this;
4684
4870
  }
4685
4871
 
@@ -4719,6 +4905,33 @@ declare class SelectQueryBuilder<T extends Model, S extends Record<string, any>
4719
4905
  * .selectFunc("custom_fn", "column", "result")
4720
4906
  */
4721
4907
  selectFunc<A extends string>(sqlFunc: SqlFunction, column: string, alias: A): this;
4908
+ /**
4909
+ * @description Adds `count(DISTINCT column)` to the SELECT list.
4910
+ * @example .countDistinct("status", "statuses").many()
4911
+ */
4912
+ countDistinct(column: string, alias: string): this;
4913
+ /**
4914
+ * @description Adds `sum(DISTINCT column)` to the SELECT list.
4915
+ */
4916
+ sumDistinct(column: string, alias: string): this;
4917
+ /**
4918
+ * @description Adds `avg(DISTINCT column)` to the SELECT list.
4919
+ */
4920
+ avgDistinct(column: string, alias: string): this;
4921
+ /**
4922
+ * @description Adds `rank() OVER (...)` to the SELECT list.
4923
+ * @example .rank("r", { partitionBy: "teamId", orderBy: { column: "score", order: "desc" } })
4924
+ */
4925
+ rank(alias?: string, options?: WindowOptions): this;
4926
+ /**
4927
+ * @description Adds `dense_rank() OVER (...)` to the SELECT list.
4928
+ */
4929
+ denseRank(alias?: string, options?: WindowOptions): this;
4930
+ /**
4931
+ * @description Adds `row_number() OVER (...)` to the SELECT list.
4932
+ */
4933
+ rowNumber(alias?: string, options?: WindowOptions): this;
4934
+ private pushWindow;
4722
4935
  /**
4723
4936
  * @description Clears the SELECT clause
4724
4937
  */
@@ -4834,9 +5047,9 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
4834
5047
  where(cb: (queryBuilder: WhereOnlyQueryBuilder<T>) => void): this;
4835
5048
  where(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4836
5049
  where(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4837
- where<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$1, value: WhereColumnValue<T, K>): this;
5050
+ where<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
4838
5051
  where<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
4839
- where<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$1, value: ResolveWhereValue<T, K>): this;
5052
+ where<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$2, value: ResolveWhereValue<T, K>): this;
4840
5053
  where<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
4841
5054
  /**
4842
5055
  * @description Adds an AND WHERE condition to the query.
@@ -4844,9 +5057,9 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
4844
5057
  andWhere(cb: (queryBuilder: WhereOnlyQueryBuilder<T>) => void): this;
4845
5058
  andWhere(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4846
5059
  andWhere(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4847
- andWhere<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$1, value: WhereColumnValue<T, K>): this;
5060
+ andWhere<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
4848
5061
  andWhere<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
4849
- andWhere<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$1, value: ResolveWhereValue<T, K>): this;
5062
+ andWhere<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$2, value: ResolveWhereValue<T, K>): this;
4850
5063
  andWhere<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
4851
5064
  /**
4852
5065
  * @description Adds an OR WHERE condition to the query.
@@ -4854,57 +5067,80 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
4854
5067
  orWhere(cb: (queryBuilder: WhereOnlyQueryBuilder<T>) => void): this;
4855
5068
  orWhere(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4856
5069
  orWhere(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4857
- orWhere<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$1, value: WhereColumnValue<T, K>): this;
5070
+ orWhere<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
4858
5071
  orWhere<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
4859
- orWhere<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$1, value: ResolveWhereValue<T, K>): this;
5072
+ orWhere<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$2, value: ResolveWhereValue<T, K>): this;
4860
5073
  orWhere<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
4861
5074
  /**
4862
5075
  * @description Adds a WHERE condition comparing two columns.
4863
5076
  */
4864
5077
  whereColumn<K extends ModelKey<T>>(column: K, referenceColumn: ModelKey<T>): this;
4865
- whereColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$1, referenceColumn: ModelKey<T>): this;
5078
+ whereColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, referenceColumn: ModelKey<T>): this;
4866
5079
  whereColumn(column: `${string}.${string}`, referenceColumn: `${string}.${string}`): this;
4867
- whereColumn(column: `${string}.${string}`, operator: BinaryOperatorType$1, referenceColumn: `${string}.${string}`): this;
5080
+ whereColumn(column: `${string}.${string}`, operator: BinaryOperatorType$2, referenceColumn: `${string}.${string}`): this;
4868
5081
  /**
4869
5082
  * @description Adds an AND WHERE condition comparing two columns.
4870
5083
  */
4871
5084
  andWhereColumn<K extends ModelKey<T>>(column: K, referenceColumn: ModelKey<T>): this;
4872
- andWhereColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$1, referenceColumn: ModelKey<T>): this;
5085
+ andWhereColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, referenceColumn: ModelKey<T>): this;
4873
5086
  andWhereColumn(column: `${string}.${string}`, referenceColumn: `${string}.${string}`): this;
4874
- andWhereColumn(column: `${string}.${string}`, operator: BinaryOperatorType$1, referenceColumn: `${string}.${string}`): this;
5087
+ andWhereColumn(column: `${string}.${string}`, operator: BinaryOperatorType$2, referenceColumn: `${string}.${string}`): this;
4875
5088
  /**
4876
5089
  * @description Adds an OR WHERE condition comparing two columns.
4877
5090
  */
4878
5091
  orWhereColumn<K extends ModelKey<T>>(column: K, referenceColumn: ModelKey<T>): this;
4879
- orWhereColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$1, referenceColumn: ModelKey<T>): this;
5092
+ orWhereColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, referenceColumn: ModelKey<T>): this;
4880
5093
  orWhereColumn(column: `${string}.${string}`, referenceColumn: `${string}.${string}`): this;
4881
- orWhereColumn(column: `${string}.${string}`, operator: BinaryOperatorType$1, referenceColumn: `${string}.${string}`): this;
5094
+ orWhereColumn(column: `${string}.${string}`, operator: BinaryOperatorType$2, referenceColumn: `${string}.${string}`): this;
5095
+ /**
5096
+ * @description Adds a WHERE condition comparing two columns with a negated
5097
+ * comparison, i.e. `column != referenceColumn` (or `NOT (column op referenceColumn)`).
5098
+ */
5099
+ whereNotColumn<K extends ModelKey<T>>(column: K, referenceColumn: ModelKey<T>): this;
5100
+ whereNotColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, referenceColumn: ModelKey<T>): this;
5101
+ whereNotColumn(column: `${string}.${string}`, referenceColumn: `${string}.${string}`): this;
5102
+ whereNotColumn(column: `${string}.${string}`, operator: BinaryOperatorType$2, referenceColumn: `${string}.${string}`): this;
5103
+ /**
5104
+ * @description Adds an AND WHERE condition comparing two columns with a negated comparison.
5105
+ */
5106
+ andWhereNotColumn<K extends ModelKey<T>>(column: K, referenceColumn: ModelKey<T>): this;
5107
+ andWhereNotColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, referenceColumn: ModelKey<T>): this;
5108
+ andWhereNotColumn(column: `${string}.${string}`, referenceColumn: `${string}.${string}`): this;
5109
+ andWhereNotColumn(column: `${string}.${string}`, operator: BinaryOperatorType$2, referenceColumn: `${string}.${string}`): this;
5110
+ /**
5111
+ * @description Adds an OR WHERE condition comparing two columns with a negated comparison.
5112
+ */
5113
+ orWhereNotColumn<K extends ModelKey<T>>(column: K, referenceColumn: ModelKey<T>): this;
5114
+ orWhereNotColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, referenceColumn: ModelKey<T>): this;
5115
+ orWhereNotColumn(column: `${string}.${string}`, referenceColumn: `${string}.${string}`): this;
5116
+ orWhereNotColumn(column: `${string}.${string}`, operator: BinaryOperatorType$2, referenceColumn: `${string}.${string}`): this;
5117
+ private pushNotColumnWhere;
4882
5118
  /**
4883
5119
  * @description Adds a negated WHERE condition to the query.
4884
5120
  */
4885
5121
  whereNot(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4886
5122
  whereNot(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4887
- whereNot<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$1, value: WhereColumnValue<T, K>): this;
5123
+ whereNot<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
4888
5124
  whereNot<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
4889
- whereNot<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$1, value: ResolveWhereValue<T, K>): this;
5125
+ whereNot<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$2, value: ResolveWhereValue<T, K>): this;
4890
5126
  whereNot<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
4891
5127
  /**
4892
5128
  * @description Adds a negated AND WHERE condition to the query.
4893
5129
  */
4894
5130
  andWhereNot(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4895
5131
  andWhereNot(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4896
- andWhereNot<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$1, value: WhereColumnValue<T, K>): this;
5132
+ andWhereNot<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
4897
5133
  andWhereNot<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
4898
- andWhereNot<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$1, value: ResolveWhereValue<T, K>): this;
5134
+ andWhereNot<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$2, value: ResolveWhereValue<T, K>): this;
4899
5135
  andWhereNot<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
4900
5136
  /**
4901
5137
  * @description Adds a negated OR WHERE condition to the query.
4902
5138
  */
4903
5139
  orWhereNot(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4904
5140
  orWhereNot(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4905
- orWhereNot<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$1, value: WhereColumnValue<T, K>): this;
5141
+ orWhereNot<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
4906
5142
  orWhereNot<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
4907
- orWhereNot<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$1, value: ResolveWhereValue<T, K>): this;
5143
+ orWhereNot<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$2, value: ResolveWhereValue<T, K>): this;
4908
5144
  orWhereNot<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
4909
5145
  /**
4910
5146
  * @description Adds a WHERE BETWEEN condition to the query.
@@ -5150,24 +5386,24 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
5150
5386
  * @description Adds a HAVING condition to the query.
5151
5387
  */
5152
5388
  having<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
5153
- having<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$1, value: WhereColumnValue<T, K>): this;
5389
+ having<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
5154
5390
  having<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
5155
- having<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$1, value: ResolveWhereValue<T, K>): this;
5391
+ having<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$2, value: ResolveWhereValue<T, K>): this;
5156
5392
  /**
5157
5393
  * @description Adds an AND HAVING condition to the query.
5158
5394
  */
5159
5395
  andHaving<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
5160
- andHaving<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$1, value: WhereColumnValue<T, K>): this;
5396
+ andHaving<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
5161
5397
  andHaving<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
5162
- andHaving<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$1, value: ResolveWhereValue<T, K>): this;
5163
- andHaving(column: ModelKey<T>, operator: BinaryOperatorType$1, value: any): this;
5398
+ andHaving<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$2, value: ResolveWhereValue<T, K>): this;
5399
+ andHaving(column: ModelKey<T>, operator: BinaryOperatorType$2, value: any): this;
5164
5400
  /**
5165
5401
  * @description Adds an OR HAVING condition to the query.
5166
5402
  */
5167
5403
  orHaving<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
5168
- orHaving<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$1, value: WhereColumnValue<T, K>): this;
5404
+ orHaving<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
5169
5405
  orHaving(column: `${string}.${string}`, value: any): this;
5170
- orHaving(column: `${string}.${string}`, operator: BinaryOperatorType$1, value: any): this;
5406
+ orHaving(column: `${string}.${string}`, operator: BinaryOperatorType$2, value: any): this;
5171
5407
  /**
5172
5408
  * @description Adds a raw HAVING condition to the query.
5173
5409
  */
@@ -5180,6 +5416,63 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
5180
5416
  * @description Adds a raw OR HAVING condition to the query.
5181
5417
  */
5182
5418
  orHavingRaw(query: string): this;
5419
+ /**
5420
+ * @description Adds a HAVING IS NULL condition.
5421
+ */
5422
+ havingNull(column: ModelKey<T> | SelectableColumn$1<string>): this;
5423
+ andHavingNull(column: ModelKey<T> | SelectableColumn$1<string>): this;
5424
+ orHavingNull(column: ModelKey<T> | SelectableColumn$1<string>): this;
5425
+ /**
5426
+ * @description Adds a HAVING IS NOT NULL condition.
5427
+ */
5428
+ havingNotNull(column: ModelKey<T> | SelectableColumn$1<string>): this;
5429
+ andHavingNotNull(column: ModelKey<T> | SelectableColumn$1<string>): this;
5430
+ orHavingNotNull(column: ModelKey<T> | SelectableColumn$1<string>): this;
5431
+ /**
5432
+ * @description Adds a HAVING IN condition; accepts values or a subquery.
5433
+ */
5434
+ havingIn(column: ModelKey<T> | SelectableColumn$1<string>, values: BaseValues$2[] | QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
5435
+ andHavingIn(column: ModelKey<T> | SelectableColumn$1<string>, values: BaseValues$2[] | QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
5436
+ orHavingIn(column: ModelKey<T> | SelectableColumn$1<string>, values: BaseValues$2[] | QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
5437
+ /**
5438
+ * @description Adds a HAVING NOT IN condition; accepts values or a subquery.
5439
+ */
5440
+ havingNotIn(column: ModelKey<T> | SelectableColumn$1<string>, values: BaseValues$2[] | QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
5441
+ andHavingNotIn(column: ModelKey<T> | SelectableColumn$1<string>, values: BaseValues$2[] | QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
5442
+ orHavingNotIn(column: ModelKey<T> | SelectableColumn$1<string>, values: BaseValues$2[] | QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
5443
+ /**
5444
+ * @description Adds a HAVING BETWEEN condition.
5445
+ */
5446
+ havingBetween(column: ModelKey<T> | SelectableColumn$1<string>, range: [BaseValues$2, BaseValues$2]): this;
5447
+ andHavingBetween(column: ModelKey<T> | SelectableColumn$1<string>, range: [BaseValues$2, BaseValues$2]): this;
5448
+ orHavingBetween(column: ModelKey<T> | SelectableColumn$1<string>, range: [BaseValues$2, BaseValues$2]): this;
5449
+ /**
5450
+ * @description Adds a HAVING NOT BETWEEN condition.
5451
+ */
5452
+ havingNotBetween(column: ModelKey<T> | SelectableColumn$1<string>, range: [BaseValues$2, BaseValues$2]): this;
5453
+ andHavingNotBetween(column: ModelKey<T> | SelectableColumn$1<string>, range: [BaseValues$2, BaseValues$2]): this;
5454
+ orHavingNotBetween(column: ModelKey<T> | SelectableColumn$1<string>, range: [BaseValues$2, BaseValues$2]): this;
5455
+ /**
5456
+ * @description Adds a HAVING EXISTS condition (subquery).
5457
+ */
5458
+ havingExists(cbOrQueryBuilder: (queryBuilder: QueryBuilder<T>) => void | QueryBuilder<T>): this;
5459
+ andHavingExists(cbOrQueryBuilder: (queryBuilder: QueryBuilder<T>) => void | QueryBuilder<T>): this;
5460
+ orHavingExists(cbOrQueryBuilder: (queryBuilder: QueryBuilder<T>) => void | QueryBuilder<T>): this;
5461
+ /**
5462
+ * @description Adds a HAVING NOT EXISTS condition (subquery).
5463
+ */
5464
+ havingNotExists(cbOrQueryBuilder: (queryBuilder: QueryBuilder<T>) => void | QueryBuilder<T>): this;
5465
+ andHavingNotExists(cbOrQueryBuilder: (queryBuilder: QueryBuilder<T>) => void | QueryBuilder<T>): this;
5466
+ orHavingNotExists(cbOrQueryBuilder: (queryBuilder: QueryBuilder<T>) => void | QueryBuilder<T>): this;
5467
+ /**
5468
+ * @description Wraps a group of HAVING conditions in parentheses.
5469
+ */
5470
+ havingWrapped(cb: (queryBuilder: WhereQueryBuilder<T>) => void): this;
5471
+ andHavingWrapped(cb: (queryBuilder: WhereQueryBuilder<T>) => void): this;
5472
+ orHavingWrapped(cb: (queryBuilder: WhereQueryBuilder<T>) => void): this;
5473
+ private pushHavingIn;
5474
+ private pushHavingExists;
5475
+ private pushHavingGroup;
5183
5476
  private buildSubQuery;
5184
5477
  private andWhereSubQuery;
5185
5478
  private orWhereSubQuery;
@@ -5264,6 +5557,77 @@ declare class JsonQueryBuilder<T extends Model, S extends Record<string, any> =
5264
5557
  * @description Add a raw JSON filter expression (OR).
5265
5558
  */
5266
5559
  orWhereJsonRaw(raw: string, params?: any[]): this;
5560
+ /**
5561
+ * @description Filters records where the JSON column equals an exact JSON object value.
5562
+ */
5563
+ whereJsonObject<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5564
+ /**
5565
+ * @description Filters records where the JSON column equals an exact JSON object value (AND).
5566
+ */
5567
+ andWhereJsonObject<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5568
+ /**
5569
+ * @description Filters records where the JSON column equals an exact JSON object value (OR).
5570
+ */
5571
+ orWhereJsonObject<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5572
+ /**
5573
+ * @description Filters records where the JSON column does NOT equal an exact JSON object value.
5574
+ */
5575
+ whereNotJsonObject<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5576
+ /**
5577
+ * @description Filters records where the JSON column does NOT equal an exact JSON object value (AND).
5578
+ */
5579
+ andWhereNotJsonObject<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5580
+ /**
5581
+ * @description Filters records where the JSON column does NOT equal an exact JSON object value (OR).
5582
+ */
5583
+ orWhereNotJsonObject<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5584
+ /**
5585
+ * @description Compares the value at a JSON path using the given operator.
5586
+ * @example whereJsonPath("meta", "address.city", "=", "Rome")
5587
+ */
5588
+ whereJsonPath<K extends string>(column: K, path: JsonPathInput, operator: BinaryOperatorType$2, value: any): this;
5589
+ /**
5590
+ * @description Compares the value at a JSON path (AND).
5591
+ */
5592
+ andWhereJsonPath<K extends string>(column: K, path: JsonPathInput, operator: BinaryOperatorType$2, value: any): this;
5593
+ /**
5594
+ * @description Compares the value at a JSON path (OR).
5595
+ */
5596
+ orWhereJsonPath<K extends string>(column: K, path: JsonPathInput, operator: BinaryOperatorType$2, value: any): this;
5597
+ /**
5598
+ * @description Filters records where the JSON column is a superset of the value (contains it).
5599
+ */
5600
+ whereJsonSupersetOf<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5601
+ andWhereJsonSupersetOf<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5602
+ orWhereJsonSupersetOf<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5603
+ /**
5604
+ * @description Filters records where the JSON column is NOT a superset of the value.
5605
+ */
5606
+ whereJsonNotSupersetOf<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5607
+ andWhereJsonNotSupersetOf<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5608
+ orWhereJsonNotSupersetOf<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5609
+ /**
5610
+ * @description Filters records where the JSON column is a subset of the value.
5611
+ * @postgres/cockroachdb/mysql/mariadb only
5612
+ */
5613
+ whereJsonSubsetOf<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5614
+ andWhereJsonSubsetOf<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5615
+ orWhereJsonSubsetOf<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5616
+ /**
5617
+ * @description Filters records where the JSON column is NOT a subset of the value.
5618
+ * @postgres/cockroachdb/mysql/mariadb only
5619
+ */
5620
+ whereJsonNotSubsetOf<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5621
+ andWhereJsonNotSubsetOf<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5622
+ orWhereJsonNotSubsetOf<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5623
+ /**
5624
+ * @description Filters records where the JSON column has none of the given keys.
5625
+ * @postgres/cockroachdb only
5626
+ */
5627
+ whereJsonHasNone<K extends string>(column: K, keys: string[]): this;
5628
+ andWhereJsonHasNone<K extends string>(column: K, keys: string[]): this;
5629
+ orWhereJsonHasNone<K extends string>(column: K, keys: string[]): this;
5630
+ private pushJsonPath;
5267
5631
  }
5268
5632
 
5269
5633
  type PluckReturnType<T extends Model, K extends RawModelKey<T>> = T[StripTablePrefix<K & string> & keyof T] extends infer U ? U[] : never;
@@ -5484,6 +5848,8 @@ interface ExecuteOptions<D extends SqlDataSourceType, M extends Model> {
5484
5848
  sqlLiteOptions?: SqlLiteOptions<M>;
5485
5849
  /** Reserved connection when inside a transaction; pool otherwise */
5486
5850
  connection?: GetConnectionReturnType<D>;
5851
+ /** Aborted when a `timeout(..., { cancel: true })` fires */
5852
+ signal?: AbortSignal;
5487
5853
  }
5488
5854
  /** rawQuery keeps transaction-level SQL flowing through the datasource (observers/logs) */
5489
5855
  type TransactionRawQuery<D extends SqlDataSourceType> = (query: string, params?: unknown[]) => Promise<RawQueryResponseType<D>>;
@@ -6045,7 +6411,7 @@ type WhereColumnValue<T extends Model, K extends ModelKey<T>> = T[StripTablePref
6045
6411
  * For model columns (ModelKey<T>), returns the specific column type.
6046
6412
  * For arbitrary columns (joins, aliases), falls back to BaseValues.
6047
6413
  */
6048
- type ResolveWhereValue<T extends Model, K extends string> = K extends ModelKey<T> ? T[StripTablePrefix<K> & keyof T] | null | SqlFuncNode : BaseValues$1;
6414
+ type ResolveWhereValue<T extends Model, K extends string> = K extends ModelKey<T> ? T[StripTablePrefix<K> & keyof T] | null | SqlFuncNode : BaseValues$2;
6049
6415
  type ModelRelation<T extends Model> = OnlyRelations<T>;
6050
6416
  type OrderByChoices = "asc" | "desc";
6051
6417
  type OrderByType<T extends Model> = {
@@ -6736,6 +7102,24 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
6736
7102
  selectFunc<F extends SqlFunction, Alias extends string>(sqlFunc: F, column: ModelKey<T> | "*" | (string & {}), alias: Alias): ModelQueryBuilder<T, ComposeSelect<S, {
6737
7103
  [K in Alias]: SqlFunctionReturnType<F>;
6738
7104
  }>, R, D>;
7105
+ countDistinct<Alias extends string = string>(column: ModelKey<T> | (string & {}), alias: Alias): ModelQueryBuilder<T, ComposeSelect<S, {
7106
+ [K in Alias]: number;
7107
+ }>, R, D>;
7108
+ sumDistinct<Alias extends string = string>(column: ModelKey<T> | (string & {}), alias: Alias): ModelQueryBuilder<T, ComposeSelect<S, {
7109
+ [K in Alias]: number;
7110
+ }>, R, D>;
7111
+ avgDistinct<Alias extends string = string>(column: ModelKey<T> | (string & {}), alias: Alias): ModelQueryBuilder<T, ComposeSelect<S, {
7112
+ [K in Alias]: number;
7113
+ }>, R, D>;
7114
+ rank<Alias extends string = never>(alias?: Alias, options?: WindowOptions): ModelQueryBuilder<T, ComposeSelect<S, {
7115
+ [K in Alias]: number;
7116
+ }>, R, D>;
7117
+ denseRank<Alias extends string = never>(alias?: Alias, options?: WindowOptions): ModelQueryBuilder<T, ComposeSelect<S, {
7118
+ [K in Alias]: number;
7119
+ }>, R, D>;
7120
+ rowNumber<Alias extends string = never>(alias?: Alias, options?: WindowOptions): ModelQueryBuilder<T, ComposeSelect<S, {
7121
+ [K in Alias]: number;
7122
+ }>, R, D>;
6739
7123
  /**
6740
7124
  * @description Clears the SELECT clause and resets to default model type
6741
7125
  * @example
@@ -7003,37 +7387,37 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
7003
7387
  * @warning All select statements are ignored, since we're only checking if the relation exists, a "select 1" will be added to the Query
7004
7388
  */
7005
7389
  havingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, cb?: (queryBuilder: ModelQueryBuilder<RelatedInstance<T, RelationKey>>) => void): this;
7006
- havingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$1 | BaseValues$1, maybeValue?: BaseValues$1): this;
7390
+ havingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$2 | BaseValues$2, maybeValue?: BaseValues$2): this;
7007
7391
  /**
7008
7392
  * @description Checks if the relation exists in the models and has the given filters, if no callback is provided, it only check if there is at least one record for the relation
7009
7393
  * @warning All select statements are ignored, since we're only checking if the relation exists, a "select 1" will be added to the Query
7010
7394
  */
7011
7395
  andHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, cb?: (queryBuilder: ModelQueryBuilder<RelatedInstance<T, RelationKey>>) => void): this;
7012
- andHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$1 | BaseValues$1, maybeValue?: BaseValues$1): this;
7396
+ andHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$2 | BaseValues$2, maybeValue?: BaseValues$2): this;
7013
7397
  /**
7014
7398
  * @description Checks if the relation exists in the models and has the given filters, if no callback is provided, it only check if there is at least one record for the relation,
7015
7399
  * @warning All select statements are ignored, since we're only checking if the relation exists, a "select 1" will be added to the Query
7016
7400
  */
7017
7401
  orHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, cb?: (queryBuilder: ModelQueryBuilder<RelatedInstance<T, RelationKey>>) => void): this;
7018
- orHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$1 | BaseValues$1, maybeValue?: BaseValues$1): this;
7402
+ orHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$2 | BaseValues$2, maybeValue?: BaseValues$2): this;
7019
7403
  /**
7020
7404
  * @description Checks if the relation does not exist in the models and has the given filters, if no callback is provided, it only check if there is no record for the Relation
7021
7405
  * @warning All select statements are ignored, since we're only checking if the relation exists, a "select 1" will be added to the Query
7022
7406
  */
7023
7407
  notHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, cb?: (queryBuilder: ModelQueryBuilder<RelatedInstance<T, RelationKey>>) => void): this;
7024
- notHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$1 | BaseValues$1, maybeValue?: BaseValues$1): this;
7408
+ notHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$2 | BaseValues$2, maybeValue?: BaseValues$2): this;
7025
7409
  /**
7026
7410
  * @description Checks if the relation does not exist in the models and has the given filters, if no callback is provided, it only check if there is no record for the relation
7027
7411
  * @warning All select statements are ignored, since we're only checking if the relation exists, a "select 1" will be added to the Query
7028
7412
  */
7029
7413
  andNotHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, cb?: (queryBuilder: ModelQueryBuilder<RelatedInstance<T, RelationKey>>) => void): this;
7030
- andNotHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$1 | BaseValues$1, maybeValue?: BaseValues$1): this;
7414
+ andNotHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$2 | BaseValues$2, maybeValue?: BaseValues$2): this;
7031
7415
  /**
7032
7416
  * @description Checks if the relation does not exist in the models and has the given filters, if no callback is provided, it only check if there is no record for the Relation
7033
7417
  * @warning All select statements are ignored, since we're only checking if the relation exists, a "select 1" will be added to the Query
7034
7418
  */
7035
7419
  orNotHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, cb?: (queryBuilder: ModelQueryBuilder<RelatedInstance<T, RelationKey>>) => void): this;
7036
- orNotHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$1 | BaseValues$1, maybeValue?: BaseValues$1): this;
7420
+ orNotHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$2 | BaseValues$2, maybeValue?: BaseValues$2): this;
7037
7421
  /**
7038
7422
  * @description Returns a copy of the query builder instance.
7039
7423
  */
@@ -7085,7 +7469,7 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
7085
7469
  protected getRelatedModelsForRelation(relationQueryBuilder: ModelQueryBuilder<any>, relation: Relation, models: T[]): Promise<SelectedModel<T, ModelWithoutRelations<T>, R>[]>;
7086
7470
  protected getRelatedModelsQueryForRelation(relationQueryBuilder: ModelQueryBuilder<any>, relation: Relation, models: T[]): ModelQueryBuilder<any, any, any, D>;
7087
7471
  protected getFilterValuesFromModelsForRelation(relation: Relation, models: T[]): any[];
7088
- protected applyHavingRelatedFilter(relationQueryBuilder: ModelQueryBuilder<any>, relation: Relation, operator?: BinaryOperatorType$1, value?: BaseValues$1): void;
7472
+ protected applyHavingRelatedFilter(relationQueryBuilder: ModelQueryBuilder<any>, relation: Relation, operator?: BinaryOperatorType$2, value?: BaseValues$2): void;
7089
7473
  }
7090
7474
 
7091
7475
  /**
@@ -8769,7 +9153,7 @@ declare abstract class BaseSeeder {
8769
9153
  abstract run(): Promise<void>;
8770
9154
  }
8771
9155
 
8772
- type HysteriaErrorCode = "VALIDATION_ERROR" | "CONNECTION_ALREADY_ESTABLISHED" | `UNSUPPORTED_ISOLATION_LEVEL_${string}` | "ROW_NOT_FOUND" | `UNSUPPORTED_DATABASE_TYPE_${string}` | `RELATION_TYPE_NOT_SUPPORTED_${string}` | `NOT_SUPPORTED_IN_${string}` | `RELATION_NOT_FOUND_IN_MODEL_${string}` | `UNKNOWN_RELATION_TYPE_${string}` | `DISTINCT_ON_NOT_SUPPORTED_IN_${string}` | `CONFLICT_COLUMNS_NOT_PRESENT_IN_DATA` | `CONFLICT_COLUMNS_NOT_PRESENT_IN_DATA_${string}` | `FOREIGN_KEY_VALUES_MISSING_FOR_HAS_ONE_RELATION_${string}` | `FOREIGN_KEY_VALUES_MISSING_FOR_BELONGS_TO_RELATION_${string}` | `PRIMARY_KEY_VALUES_MISSING_FOR_HAS_MANY_RELATION_${string}` | `MANY_TO_MANY_RELATION_NOT_FOUND_FOR_RELATED_MODEL_${string}` | `PRIMARY_KEY_VALUES_MISSING_FOR_MANY_TO_MANY_RELATION_${string}` | `RELATED_MODEL_DOES_NOT_HAVE_A_PRIMARY_KEY_${string}` | `FOR_SHARE_NOT_SUPPORTED_IN_${string}` | `SKIP_LOCKED_NOT_SUPPORTED_IN_${string}` | `LOCK_FOR_UPDATE_NOT_SUPPORTED_${string}` | `KEY_${string}_HAS_NO_HANDLER_IN_CACHE_KEYS_CONFIG` | `CACHE_ADAPTER_NOT_CONFIGURED` | `SQLITE_NOT_SUPPORTED` | `COCKROACHDB_NOT_SUPPORTED` | `RELATION_NOT_FOUND` | `POSTGRES_TABLE_REQUIRED` | `MODEL_HAS_NO_PRIMARY_KEY_VALUE` | `RELATION_NOT_MANY_TO_MANY` | "MATERIALIZED_CTE_NOT_SUPPORTED" | "DUPLICATE_MODEL_KEYS_WHILE_INSTANTIATING_MODELS" | "INVALID_ONE_PARAMETER_WHERE_CONDITION" | "INVALID_PAGINATION_PARAMETERS" | "MISSING_ALIAS_FOR_SUBQUERY" | "MODEL_HAS_NO_PRIMARY_KEY" | "PRIMARY_KEY_NOT_FOUND" | "ORDER_BY_REQUIRED" | "ORDER_BY_RAW_NOT_SUPPORTED" | "INVALID_SQL_COMMENT" | "SQLITE_ONLY_SUPPORTS_SERIALIZABLE_ISOLATION_LEVEL" | "MUST_CALL_BUILD_CTE_AT_LEAST_ONCE" | "REGEXP_NOT_SUPPORTED_IN_SQLITE" | "MANY_TO_MANY_RELATION_MUST_HAVE_A_THROUGH_MODEL" | "INSERT_FAILED" | "MULTIPLE_PRIMARY_KEYS_NOT_ALLOWED" | "FILE_NOT_A_SQL_OR_TXT_FILE" | "CONNECTION_NOT_ESTABLISHED" | "TRANSACTION_NOT_ACTIVE" | "DEVELOPMENT_ERROR" | "MIGRATION_MODULE_NOT_FOUND" | "DRIVER_NOT_FOUND" | "FILE_NOT_FOUND_OR_NOT_ACCESSIBLE" | "ENV_NOT_SET" | "REQUIRED_VALUE_NOT_SET" | "SET_FAILED" | "GET_FAILED" | "REFERENCES_OPTION_REQUIRED" | "DELETE_FAILED" | "INVALID_DEFAULT_VALUE" | "DISCONNECT_FAILED" | "FLUSH_FAILED" | "LEFT_COLUMN_NOT_PROVIDED_FOR_JOIN" | "RIGHT_COLUMN_NOT_PROVIDED_FOR_JOIN" | "MODEL_HAS_NO_PRIMARY_KEY" | "GLOBAL_TRANSACTION_ALREADY_STARTED" | "GLOBAL_TRANSACTION_NOT_STARTED" | "MYSQL_REQUIRES_TABLE_NAME_FOR_INDEX_DROP" | "INVALID_DATE_OBJECT" | "INVALID_DATE_STRING" | "FAILED_TO_PARSE_DATE" | "MIGRATION_MODULE_REQUIRES_TS_NODE" | "FAILED_TO_ENCRYPT_SYMMETRICALLY" | "FAILED_TO_DECRYPT_SYMMETRICALLY" | "FAILED_TO_ENCRYPT_ASYMMETRICALLY" | "FAILED_TO_DECRYPT_ASYMMETRICALLY" | "UNSUPPORTED_RELATION_TYPE" | "LPUSH_FAILED" | "RPUSH_FAILED" | "LPOP_FAILED" | "RPOP_FAILED" | "LRANGE_FAILED" | "LLEN_FAILED" | "HSET_FAILED" | "HMSET_FAILED" | "HGET_FAILED" | "HGETALL_FAILED" | "HMGET_FAILED" | "HDEL_FAILED" | "HEXISTS_FAILED" | "HKEYS_FAILED" | "HLEN_FAILED" | "SADD_FAILED" | "SMEMBERS_FAILED" | "SREM_FAILED" | "SISMEMBER_FAILED" | "SCARD_FAILED" | "SINTER_FAILED" | "SUNION_FAILED" | "SDIFF_FAILED" | "ZADD_FAILED" | "ZRANGE_FAILED" | "ZREVRANGE_FAILED" | "ZREM_FAILED" | "ZSCORE_FAILED" | "ZCARD_FAILED" | "SUBSCRIBE_FAILED" | "UNSUBSCRIBE_FAILED" | "PUBLISH_FAILED" | "PSUBSCRIBE_FAILED" | "PUNSUBSCRIBE_FAILED" | "EXISTS_FAILED" | "EXPIRE_FAILED" | "EXPIREAT_FAILED" | "PEXPIRE_FAILED" | "TTL_FAILED" | "PTTL_FAILED" | "PERSIST_FAILED" | "KEYS_FAILED" | "RENAME_FAILED" | "TYPE_FAILED" | "SCAN_FAILED" | "ADMINJS_NOT_ENABLED" | "ADMINJS_INITIALIZATION_FAILED" | "ADMINJS_NO_MODELS_PROVIDED" | `BETTER_AUTH_MISSING_ID_${string}` | `BETTER_AUTH_INVALID_INCREMENT_${string}` | "ZOD_ENGINE_NOT_LOADED" | "ATOMIC_DATASOURCE_RESOLUTION_FAILED" | "ATOMIC_INVALID_METHOD" | "ATOMIC_CLS_DISABLED" | `SCOPE_NOT_FOUND_${string}`;
9156
+ type HysteriaErrorCode = "VALIDATION_ERROR" | "CONNECTION_ALREADY_ESTABLISHED" | `UNSUPPORTED_ISOLATION_LEVEL_${string}` | "ROW_NOT_FOUND" | `UNSUPPORTED_DATABASE_TYPE_${string}` | `RELATION_TYPE_NOT_SUPPORTED_${string}` | `NOT_SUPPORTED_IN_${string}` | `RELATION_NOT_FOUND_IN_MODEL_${string}` | `UNKNOWN_RELATION_TYPE_${string}` | `DISTINCT_ON_NOT_SUPPORTED_IN_${string}` | `CONFLICT_COLUMNS_NOT_PRESENT_IN_DATA` | `CONFLICT_COLUMNS_NOT_PRESENT_IN_DATA_${string}` | `FOREIGN_KEY_VALUES_MISSING_FOR_HAS_ONE_RELATION_${string}` | `FOREIGN_KEY_VALUES_MISSING_FOR_BELONGS_TO_RELATION_${string}` | `PRIMARY_KEY_VALUES_MISSING_FOR_HAS_MANY_RELATION_${string}` | `MANY_TO_MANY_RELATION_NOT_FOUND_FOR_RELATED_MODEL_${string}` | `PRIMARY_KEY_VALUES_MISSING_FOR_MANY_TO_MANY_RELATION_${string}` | `RELATED_MODEL_DOES_NOT_HAVE_A_PRIMARY_KEY_${string}` | `FOR_SHARE_NOT_SUPPORTED_IN_${string}` | `SKIP_LOCKED_NOT_SUPPORTED_IN_${string}` | `LOCK_STRENGTH_NOT_SUPPORTED_IN_${string}` | "QUERY_TIMEOUT" | `LOCK_FOR_UPDATE_NOT_SUPPORTED_${string}` | `KEY_${string}_HAS_NO_HANDLER_IN_CACHE_KEYS_CONFIG` | `CACHE_ADAPTER_NOT_CONFIGURED` | `SQLITE_NOT_SUPPORTED` | `COCKROACHDB_NOT_SUPPORTED` | `RELATION_NOT_FOUND` | `POSTGRES_TABLE_REQUIRED` | `MODEL_HAS_NO_PRIMARY_KEY_VALUE` | `RELATION_NOT_MANY_TO_MANY` | "MATERIALIZED_CTE_NOT_SUPPORTED" | "NOT_MATERIALIZED_CTE_NOT_SUPPORTED" | "USING_REQUIRES_JOIN" | "USING_NOT_SUPPORTED_IN_MSSQL" | "DUPLICATE_MODEL_KEYS_WHILE_INSTANTIATING_MODELS" | "INVALID_ONE_PARAMETER_WHERE_CONDITION" | "INVALID_PAGINATION_PARAMETERS" | "MISSING_ALIAS_FOR_SUBQUERY" | "MODEL_HAS_NO_PRIMARY_KEY" | "PRIMARY_KEY_NOT_FOUND" | "ORDER_BY_REQUIRED" | "ORDER_BY_RAW_NOT_SUPPORTED" | "INVALID_SQL_COMMENT" | "SQLITE_ONLY_SUPPORTS_SERIALIZABLE_ISOLATION_LEVEL" | "MUST_CALL_BUILD_CTE_AT_LEAST_ONCE" | "REGEXP_NOT_SUPPORTED_IN_SQLITE" | "MANY_TO_MANY_RELATION_MUST_HAVE_A_THROUGH_MODEL" | "INSERT_FAILED" | "MULTIPLE_PRIMARY_KEYS_NOT_ALLOWED" | "FILE_NOT_A_SQL_OR_TXT_FILE" | "CONNECTION_NOT_ESTABLISHED" | "TRANSACTION_NOT_ACTIVE" | "DEVELOPMENT_ERROR" | "MIGRATION_MODULE_NOT_FOUND" | "DRIVER_NOT_FOUND" | "FILE_NOT_FOUND_OR_NOT_ACCESSIBLE" | "ENV_NOT_SET" | "REQUIRED_VALUE_NOT_SET" | "SET_FAILED" | "GET_FAILED" | "REFERENCES_OPTION_REQUIRED" | "DELETE_FAILED" | "INVALID_DEFAULT_VALUE" | "DISCONNECT_FAILED" | "FLUSH_FAILED" | "LEFT_COLUMN_NOT_PROVIDED_FOR_JOIN" | "RIGHT_COLUMN_NOT_PROVIDED_FOR_JOIN" | "MODEL_HAS_NO_PRIMARY_KEY" | "GLOBAL_TRANSACTION_ALREADY_STARTED" | "GLOBAL_TRANSACTION_NOT_STARTED" | "MYSQL_REQUIRES_TABLE_NAME_FOR_INDEX_DROP" | "INVALID_DATE_OBJECT" | "INVALID_DATE_STRING" | "FAILED_TO_PARSE_DATE" | "MIGRATION_MODULE_REQUIRES_TS_NODE" | "FAILED_TO_ENCRYPT_SYMMETRICALLY" | "FAILED_TO_DECRYPT_SYMMETRICALLY" | "FAILED_TO_ENCRYPT_ASYMMETRICALLY" | "FAILED_TO_DECRYPT_ASYMMETRICALLY" | "UNSUPPORTED_RELATION_TYPE" | "LPUSH_FAILED" | "RPUSH_FAILED" | "LPOP_FAILED" | "RPOP_FAILED" | "LRANGE_FAILED" | "LLEN_FAILED" | "HSET_FAILED" | "HMSET_FAILED" | "HGET_FAILED" | "HGETALL_FAILED" | "HMGET_FAILED" | "HDEL_FAILED" | "HEXISTS_FAILED" | "HKEYS_FAILED" | "HLEN_FAILED" | "SADD_FAILED" | "SMEMBERS_FAILED" | "SREM_FAILED" | "SISMEMBER_FAILED" | "SCARD_FAILED" | "SINTER_FAILED" | "SUNION_FAILED" | "SDIFF_FAILED" | "ZADD_FAILED" | "ZRANGE_FAILED" | "ZREVRANGE_FAILED" | "ZREM_FAILED" | "ZSCORE_FAILED" | "ZCARD_FAILED" | "SUBSCRIBE_FAILED" | "UNSUBSCRIBE_FAILED" | "PUBLISH_FAILED" | "PSUBSCRIBE_FAILED" | "PUNSUBSCRIBE_FAILED" | "EXISTS_FAILED" | "EXPIRE_FAILED" | "EXPIREAT_FAILED" | "PEXPIRE_FAILED" | "TTL_FAILED" | "PTTL_FAILED" | "PERSIST_FAILED" | "KEYS_FAILED" | "RENAME_FAILED" | "TYPE_FAILED" | "SCAN_FAILED" | "ADMINJS_NOT_ENABLED" | "ADMINJS_INITIALIZATION_FAILED" | "ADMINJS_NO_MODELS_PROVIDED" | `BETTER_AUTH_MISSING_ID_${string}` | `BETTER_AUTH_INVALID_INCREMENT_${string}` | "ZOD_ENGINE_NOT_LOADED" | "ATOMIC_DATASOURCE_RESOLUTION_FAILED" | "ATOMIC_INVALID_METHOD" | "ATOMIC_CLS_DISABLED" | `SCOPE_NOT_FOUND_${string}`;
8773
9157
 
8774
9158
  declare class HysteriaError extends Error {
8775
9159
  code: HysteriaErrorCode;