hysteria-orm 12.1.0 → 12.2.0

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
@@ -2987,6 +3093,38 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
2987
3093
  skipLocked?: boolean;
2988
3094
  noWait?: boolean;
2989
3095
  }): this;
3096
+ /**
3097
+ * @description Locks the selected rows with the `FOR NO KEY UPDATE` strength.
3098
+ * Weaker than `FOR UPDATE`: it does not block foreign keys that reference the row.
3099
+ * @postgres only
3100
+ * @throws HysteriaError if the database type is not postgres
3101
+ */
3102
+ forNoKeyUpdate(options?: {
3103
+ skipLocked?: boolean;
3104
+ noWait?: boolean;
3105
+ }): this;
3106
+ /**
3107
+ * @description Locks the selected rows with the `FOR KEY SHARE` strength.
3108
+ * The weakest row lock: only blocks updates that change a key value.
3109
+ * @postgres only
3110
+ * @throws HysteriaError if the database type is not postgres
3111
+ */
3112
+ forKeyShare(options?: {
3113
+ skipLocked?: boolean;
3114
+ noWait?: boolean;
3115
+ }): this;
3116
+ private assertPgLockStrength;
3117
+ /**
3118
+ * @description Sets a wall-clock timeout for this query. When exceeded the
3119
+ * query rejects with a `QUERY_TIMEOUT` HysteriaError.
3120
+ * @param ms - Maximum execution time in milliseconds
3121
+ * @param options.cancel - When true, ask the driver to cancel the running
3122
+ * query. Honored by PostgreSQL and MySQL/MariaDB; MSSQL cancels its request;
3123
+ * SQLite and Bun have no cancellation and only enforce the timeout.
3124
+ */
3125
+ timeout(ms: number, options?: {
3126
+ cancel?: boolean;
3127
+ }): this;
2990
3128
  /**
2991
3129
  * @description Prepends a native SQL comment to the select statement, in the
2992
3130
  * syntax of the active dialect (e.g. `-- line`, `/* block *\/`; MySQL adds
@@ -3029,6 +3167,17 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3029
3167
  unionAll(query: string, bindings?: any[]): this;
3030
3168
  unionAll(cb: UnionCallBack<T>): this;
3031
3169
  unionAll(queryBuilder: QueryBuilder<any>): this;
3170
+ /**
3171
+ * @description Adds an INTERSECT to the query (keeps only rows present in both queries).
3172
+ */
3173
+ intersect(query: string): this;
3174
+ intersect(cb: UnionCallBack<T>): this;
3175
+ /**
3176
+ * @description Adds an EXCEPT to the query (keeps rows from the first query not present in the second).
3177
+ */
3178
+ except(query: string): this;
3179
+ except(cb: UnionCallBack<T>): this;
3180
+ private resolveSetOperationNodes;
3032
3181
  /**
3033
3182
  * @description Increments the value of a column by a given amount
3034
3183
  * @typeSafe - In typescript, only numeric columns of the model will be accepted if using a Model
@@ -3079,6 +3228,12 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3079
3228
  * @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
3229
  */
3081
3230
  getSum(column: string): Promise<number>;
3231
+ /**
3232
+ * @description Introspects column metadata for the query's table. With a
3233
+ * column name it returns that column's info, otherwise every column.
3234
+ */
3235
+ columnInfo(): Promise<TableColumnInfo[]>;
3236
+ columnInfo(column: string): Promise<TableColumnInfo | undefined>;
3082
3237
  /**
3083
3238
  * @description Executes the query and retrieves multiple paginated results.
3084
3239
  * @description Overrides the limit and offset clauses in order to paginate the results.
@@ -3090,6 +3245,16 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3090
3245
  */
3091
3246
  table<S extends string>(table: TableFormat<S>, maybeAlias?: string): this;
3092
3247
  table<S extends string>(cb: (qb: QueryBuilder<T>) => void | SubQueryable, alias: string): this;
3248
+ /**
3249
+ * @description Sets the schema (search path) applied to every table reference in
3250
+ * this query, rendering two-part names such as `schema.table`.
3251
+ */
3252
+ withSchema(schemaName: string): this;
3253
+ /**
3254
+ * @description Uses a raw SQL fragment as the FROM source. `?` placeholders are
3255
+ * rewritten to the dialect's placeholders, in order with the rest of the query.
3256
+ */
3257
+ fromRaw(raw: string, bindings?: any[]): this;
3093
3258
  /**
3094
3259
  * @description Adds a CTE to the query using a callback to build the subquery.
3095
3260
  */
@@ -3105,6 +3270,12 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3105
3270
  * @throws HysteriaError if the database type is not postgres or cockroachdb
3106
3271
  */
3107
3272
  withMaterialized(alias: string, cb: (qb: QueryBuilder<T>) => void | SubQueryable): this;
3273
+ /**
3274
+ * @description Adds a non-materialized CTE to the query using a callback to build the subquery.
3275
+ * @postgres only
3276
+ * @throws HysteriaError if the database type is not postgres or cockroachdb
3277
+ */
3278
+ withNotMaterialized(alias: string, cb: (qb: QueryBuilder<T>) => void | SubQueryable): this;
3108
3279
  /**
3109
3280
  * @description Insert record into a table, you can use raw statements in the data object for literal references to other columns
3110
3281
  * @param returning - The columns to return from the query, only supported by postgres and cockroachdb - default is "*"
@@ -3238,49 +3409,6 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3238
3409
  protected execSqlWithSlaveHandling<R>(mode: "read" | "write", operation: (dataSource: SqlDataSource) => Promise<R>): Promise<R>;
3239
3410
  }
3240
3411
 
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
3412
  type Returning = "rows" | "affectedRows" | "raw";
3285
3413
  /**
3286
3414
  * @description Maps a SqlDataSourceType to the raw driver response type
@@ -3637,6 +3765,11 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
3637
3765
  * ```
3638
3766
  */
3639
3767
  from<S extends string>(table: TableFormat<S>, options?: RawModelOptions): QueryBuilder<any, Record<string, any>, D>;
3768
+ /**
3769
+ * @description Starts a query from a raw SQL fragment, e.g. a table-valued
3770
+ * function or a derived table. `?` placeholders are rewritten per dialect.
3771
+ */
3772
+ fromRaw(raw: string, bindings?: any[], options?: RawModelOptions): QueryBuilder<any, Record<string, any>, D>;
3640
3773
  /**
3641
3774
  * @description Returns a SchemaBuilder instance for DDL operations
3642
3775
  * @description The builder will execute queries when awaited or when .execute() is called
@@ -3751,6 +3884,20 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
3751
3884
  * ```
3752
3885
  */
3753
3886
  rawStatement(value: string): RawNode;
3887
+ /**
3888
+ * @description Sets a value at a JSON path, replacing any existing value.
3889
+ * Use as an update value: `update({ meta: sql.jsonSet("meta", "$.a", 1) })`.
3890
+ */
3891
+ jsonSet(column: string, path: JsonPath, value: unknown, alias?: string): JsonMutationNode;
3892
+ /**
3893
+ * @description Inserts a value at a JSON path only when the path is absent.
3894
+ * Use as an update value.
3895
+ */
3896
+ jsonInsert(column: string, path: JsonPath, value: unknown, alias?: string): JsonMutationNode;
3897
+ /**
3898
+ * @description Removes the value at a JSON path. Use as an update value.
3899
+ */
3900
+ jsonRemove(column: string, path: JsonPath, alias?: string): JsonMutationNode;
3754
3901
  /**
3755
3902
  * @description Retrieves information from the database for the given table
3756
3903
  */
@@ -3937,11 +4084,13 @@ declare class SelectNode extends QueryNode {
3937
4084
  column: string | QueryNode | QueryNode[];
3938
4085
  alias?: string;
3939
4086
  sqlFunction?: string;
4087
+ /** Renders the aggregate as `fn(DISTINCT col)` (e.g. count/sum/avg). */
4088
+ distinct?: boolean;
3940
4089
  chainsWith: string;
3941
4090
  canKeywordBeSeenMultipleTimes: boolean;
3942
4091
  folder: string;
3943
4092
  file: string;
3944
- constructor(column: string | QueryNode | QueryNode[], alias?: string, sqlFunction?: string, isRaw?: boolean);
4093
+ constructor(column: string | QueryNode | QueryNode[], alias?: string, sqlFunction?: string, isRaw?: boolean, distinct?: boolean);
3945
4094
  }
3946
4095
 
3947
4096
  declare class JoinNode extends QueryNode {
@@ -3959,6 +4108,10 @@ declare class JoinNode extends QueryNode {
3959
4108
  file: string;
3960
4109
  type: "inner" | "left" | "right" | "full" | "cross" | "natural";
3961
4110
  additionalConditions?: (WhereNode | WhereGroupNode | WhereSubqueryNode)[];
4111
+ /** When set, renders `using (cols)` instead of an `on` condition. */
4112
+ using?: string[];
4113
+ /** Schema applied to the joined table reference. */
4114
+ schema?: string;
3962
4115
  constructor(table: string, left: string, right: string, type: "inner" | "left" | "right" | "full" | "cross" | "natural" | undefined, on: {
3963
4116
  left?: string;
3964
4117
  right?: string;
@@ -4377,60 +4530,60 @@ declare class JoinOnQueryBuilder {
4377
4530
  /**
4378
4531
  * @description Adds a WHERE condition to the query.
4379
4532
  */
4380
- where(column: SelectableColumn$1<string>, operator: BinaryOperatorType$1, value: BaseValues$1): this;
4533
+ where(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
4381
4534
  where(cb: (queryBuilder: JoinOnQueryBuilder) => void): this;
4382
- where(column: SelectableColumn$1<string>, value: BaseValues$1): this;
4535
+ where(column: SelectableColumn$1<string>, value: BaseValues$2): this;
4383
4536
  /**
4384
4537
  * @description Adds an AND WHERE condition to the query.
4385
4538
  */
4386
- andWhere(column: SelectableColumn$1<string>, operator: BinaryOperatorType$1, value: BaseValues$1): this;
4387
- andWhere(column: SelectableColumn$1<string>, value: BaseValues$1): this;
4539
+ andWhere(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
4540
+ andWhere(column: SelectableColumn$1<string>, value: BaseValues$2): this;
4388
4541
  andWhere(cb: (queryBuilder: JoinOnQueryBuilder) => void): this;
4389
4542
  /**
4390
4543
  * @description Adds an OR WHERE condition to the query.
4391
4544
  */
4392
- orWhere(column: SelectableColumn$1<string>, operator: BinaryOperatorType$1, value: BaseValues$1): this;
4393
- orWhere(column: SelectableColumn$1<string>, value: BaseValues$1): this;
4545
+ orWhere(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
4546
+ orWhere(column: SelectableColumn$1<string>, value: BaseValues$2): this;
4394
4547
  orWhere(cb: (queryBuilder: JoinOnQueryBuilder) => void): this;
4395
4548
  /**
4396
4549
  * @description Adds a negated WHERE condition to the query.
4397
4550
  */
4398
- whereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$1, value: BaseValues$1): this;
4399
- whereNot(column: SelectableColumn$1<string>, value: BaseValues$1): this;
4551
+ whereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
4552
+ whereNot(column: SelectableColumn$1<string>, value: BaseValues$2): this;
4400
4553
  /**
4401
4554
  * @description Adds a negated AND WHERE condition to the query.
4402
4555
  */
4403
- andWhereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$1, value: BaseValues$1): this;
4404
- andWhereNot(column: SelectableColumn$1<string>, value: BaseValues$1): this;
4556
+ andWhereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
4557
+ andWhereNot(column: SelectableColumn$1<string>, value: BaseValues$2): this;
4405
4558
  /**
4406
4559
  * @description Adds a negated OR WHERE condition to the query.
4407
4560
  */
4408
- orWhereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$1, value: BaseValues$1): this;
4409
- orWhereNot(column: SelectableColumn$1<string>, value: BaseValues$1): this;
4561
+ orWhereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
4562
+ orWhereNot(column: SelectableColumn$1<string>, value: BaseValues$2): this;
4410
4563
  /**
4411
4564
  * @description Adds a WHERE BETWEEN condition to the query.
4412
4565
  */
4413
- whereBetween(column: SelectableColumn$1<string>, min: BaseValues$1, max: BaseValues$1): this;
4566
+ whereBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
4414
4567
  /**
4415
4568
  * @description Adds an AND WHERE BETWEEN condition to the query.
4416
4569
  */
4417
- andWhereBetween(column: SelectableColumn$1<string>, min: BaseValues$1, max: BaseValues$1): this;
4570
+ andWhereBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
4418
4571
  /**
4419
4572
  * @description Adds an OR WHERE BETWEEN condition to the query.
4420
4573
  */
4421
- orWhereBetween(column: SelectableColumn$1<string>, min: BaseValues$1, max: BaseValues$1): this;
4574
+ orWhereBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
4422
4575
  /**
4423
4576
  * @description Adds a WHERE NOT BETWEEN condition to the query.
4424
4577
  */
4425
- whereNotBetween(column: SelectableColumn$1<string>, min: BaseValues$1, max: BaseValues$1): this;
4578
+ whereNotBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
4426
4579
  /**
4427
4580
  * @description Adds an AND WHERE NOT BETWEEN condition to the query.
4428
4581
  */
4429
- andWhereNotBetween(column: SelectableColumn$1<string>, min: BaseValues$1, max: BaseValues$1): this;
4582
+ andWhereNotBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
4430
4583
  /**
4431
4584
  * @description Adds an OR WHERE NOT BETWEEN condition to the query.
4432
4585
  */
4433
- orWhereNotBetween(column: SelectableColumn$1<string>, min: BaseValues$1, max: BaseValues$1): this;
4586
+ orWhereNotBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
4434
4587
  /**
4435
4588
  * @description Adds a WHERE LIKE condition to the query.
4436
4589
  */
@@ -4482,27 +4635,27 @@ declare class JoinOnQueryBuilder {
4482
4635
  /**
4483
4636
  * @description Adds a WHERE IN condition to the query.
4484
4637
  */
4485
- whereIn(column: SelectableColumn$1<string>, values: BaseValues$1[]): this;
4638
+ whereIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
4486
4639
  /**
4487
4640
  * @description Adds an AND WHERE IN condition to the query.
4488
4641
  */
4489
- andWhereIn(column: SelectableColumn$1<string>, values: BaseValues$1[]): this;
4642
+ andWhereIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
4490
4643
  /**
4491
4644
  * @description Adds an OR WHERE IN condition to the query.
4492
4645
  */
4493
- orWhereIn(column: SelectableColumn$1<string>, values: BaseValues$1[]): this;
4646
+ orWhereIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
4494
4647
  /**
4495
4648
  * @description Adds a WHERE NOT IN condition to the query.
4496
4649
  */
4497
- whereNotIn(column: SelectableColumn$1<string>, values: BaseValues$1[]): this;
4650
+ whereNotIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
4498
4651
  /**
4499
4652
  * @description Adds an AND WHERE NOT IN condition to the query.
4500
4653
  */
4501
- andWhereNotIn(column: SelectableColumn$1<string>, values: BaseValues$1[]): this;
4654
+ andWhereNotIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
4502
4655
  /**
4503
4656
  * @description Adds an OR WHERE NOT IN condition to the query.
4504
4657
  */
4505
- orWhereNotIn(column: SelectableColumn$1<string>, values: BaseValues$1[]): this;
4658
+ orWhereNotIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
4506
4659
  /**
4507
4660
  * @description Adds a WHERE NULL condition to the query.
4508
4661
  */
@@ -4566,15 +4719,15 @@ declare class JoinOnQueryBuilder {
4566
4719
  /**
4567
4720
  * @description Adds a raw WHERE condition to the query.
4568
4721
  */
4569
- whereRaw(sql: string, bindings?: BaseValues$1[]): this;
4722
+ whereRaw(sql: string, bindings?: BaseValues$2[]): this;
4570
4723
  /**
4571
4724
  * @description Adds an AND raw WHERE condition to the query.
4572
4725
  */
4573
- andWhereRaw(sql: string, bindings?: BaseValues$1[]): this;
4726
+ andWhereRaw(sql: string, bindings?: BaseValues$2[]): this;
4574
4727
  /**
4575
4728
  * @description Adds an OR raw WHERE condition to the query.
4576
4729
  */
4577
- orWhereRaw(sql: string, bindings?: BaseValues$1[]): this;
4730
+ orWhereRaw(sql: string, bindings?: BaseValues$2[]): this;
4578
4731
  }
4579
4732
 
4580
4733
  /**
@@ -4608,6 +4761,17 @@ declare abstract class JoinQueryBuilder<T extends Model, S extends Record<string
4608
4761
  * @description Join a table with the current model, join clause is not necessary and will be added automatically
4609
4762
  */
4610
4763
  crossJoinRaw(query: string): this;
4764
+ /**
4765
+ * @description Performs a CROSS JOIN against a table (non-raw).
4766
+ */
4767
+ crossJoin(relationTable: string, alias?: string): this;
4768
+ crossJoin<R extends AnyModelConstructor>(relationModel: R): this;
4769
+ /**
4770
+ * @description Replaces the ON condition of the most recently added join with a
4771
+ * `USING (columns)` clause, e.g. `join("orders").using("user_id")`.
4772
+ * @postgres/mysql/mariadb/cockroachdb/sqlite only
4773
+ */
4774
+ using(...columns: (JoinableColumn | ModelKey<T>)[]): this;
4611
4775
  /**
4612
4776
  * @description Join a table with the current model, join clause is not necessary and will be added automatically
4613
4777
  */
@@ -4619,13 +4783,14 @@ declare abstract class JoinQueryBuilder<T extends Model, S extends Record<string
4619
4783
  * @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
4784
  * @param operator - The comparison operator to use in the ON clause (default: "=")
4621
4785
  */
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;
4786
+ innerJoin(relationTable: string): this;
4787
+ innerJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$2): this;
4788
+ innerJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$2): this;
4789
+ innerJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator?: BinaryOperatorType$2): this;
4790
+ innerJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn?: ModelKey<T>, operator?: BinaryOperatorType$2): this;
4791
+ innerJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator: BinaryOperatorType$2, callback: JoinOnCallback): this;
4627
4792
  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;
4793
+ innerJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator: BinaryOperatorType$2, callback: JoinOnCallback): this;
4629
4794
  innerJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, callback: JoinOnCallback): this;
4630
4795
  /**
4631
4796
  * @description Join a table with the current model
@@ -4634,13 +4799,14 @@ declare abstract class JoinQueryBuilder<T extends Model, S extends Record<string
4634
4799
  * @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
4800
  * @param operator - The comparison operator to use in the ON clause (default: "=")
4636
4801
  */
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;
4802
+ join(relationTable: string): this;
4803
+ join(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$2): this;
4804
+ join(relationTable: string, referencingColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$2): this;
4805
+ join<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator?: BinaryOperatorType$2): this;
4806
+ join<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn?: ModelKey<T>, operator?: BinaryOperatorType$2): this;
4807
+ join(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator: BinaryOperatorType$2, callback: JoinOnCallback): this;
4642
4808
  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;
4809
+ join<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator: BinaryOperatorType$2, callback: JoinOnCallback): this;
4644
4810
  join<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, callback: JoinOnCallback): this;
4645
4811
  /**
4646
4812
  * @description Join a table with the current model
@@ -4649,13 +4815,14 @@ declare abstract class JoinQueryBuilder<T extends Model, S extends Record<string
4649
4815
  * @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
4816
  * @param operator - The comparison operator to use in the ON clause (default: "=")
4651
4817
  */
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;
4818
+ leftJoin(relationTable: string): this;
4819
+ leftJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$2): this;
4820
+ leftJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$2): this;
4821
+ leftJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator?: BinaryOperatorType$2): this;
4822
+ leftJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn?: ModelKey<T>, operator?: BinaryOperatorType$2): this;
4823
+ leftJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator: BinaryOperatorType$2, callback: JoinOnCallback): this;
4657
4824
  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;
4825
+ leftJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator: BinaryOperatorType$2, callback: JoinOnCallback): this;
4659
4826
  leftJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, callback: JoinOnCallback): this;
4660
4827
  /**
4661
4828
  * @description Join a table with the current model
@@ -4664,10 +4831,11 @@ declare abstract class JoinQueryBuilder<T extends Model, S extends Record<string
4664
4831
  * @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
4832
  * @param operator - The comparison operator to use in the ON clause (default: "=")
4666
4833
  */
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;
4834
+ rightJoin(relationTable: string): this;
4835
+ rightJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$2): this;
4836
+ rightJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$2): this;
4837
+ rightJoin<R extends AnyModelConstructor>(relationTable: string | R, referencingColumnOrPrimaryColumn: ModelKey<InstanceType<R>> | JoinableColumn | ModelKey<T>, primaryColumn?: JoinableColumn | ModelKey<T>, operator?: BinaryOperatorType$2): this;
4838
+ rightJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, operator: BinaryOperatorType$2, callback: JoinOnCallback): this;
4671
4839
  rightJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, callback: JoinOnCallback): this;
4672
4840
  /**
4673
4841
  * @description Perform a FULL OUTER JOIN with another table
@@ -4676,10 +4844,10 @@ declare abstract class JoinQueryBuilder<T extends Model, S extends Record<string
4676
4844
  * @param primaryColumn - The primary column of the current model
4677
4845
  * @param operator - The comparison operator to use in the ON clause (default: "=")
4678
4846
  */
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;
4847
+ fullJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$2): this;
4848
+ fullJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$2): this;
4849
+ fullJoin<R extends AnyModelConstructor>(relationTable: string | R, referencingColumnOrPrimaryColumn: ModelKey<InstanceType<R>> | JoinableColumn | ModelKey<T>, primaryColumn?: JoinableColumn | ModelKey<T>, operator?: BinaryOperatorType$2): this;
4850
+ fullJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, operator: BinaryOperatorType$2, callback: JoinOnCallback): this;
4683
4851
  fullJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, callback: JoinOnCallback): this;
4684
4852
  }
4685
4853
 
@@ -4719,6 +4887,33 @@ declare class SelectQueryBuilder<T extends Model, S extends Record<string, any>
4719
4887
  * .selectFunc("custom_fn", "column", "result")
4720
4888
  */
4721
4889
  selectFunc<A extends string>(sqlFunc: SqlFunction, column: string, alias: A): this;
4890
+ /**
4891
+ * @description Adds `count(DISTINCT column)` to the SELECT list.
4892
+ * @example .countDistinct("status", "statuses").many()
4893
+ */
4894
+ countDistinct(column: string, alias?: string): this;
4895
+ /**
4896
+ * @description Adds `sum(DISTINCT column)` to the SELECT list.
4897
+ */
4898
+ sumDistinct(column: string, alias?: string): this;
4899
+ /**
4900
+ * @description Adds `avg(DISTINCT column)` to the SELECT list.
4901
+ */
4902
+ avgDistinct(column: string, alias?: string): this;
4903
+ /**
4904
+ * @description Adds `rank() OVER (...)` to the SELECT list.
4905
+ * @example .rank("r", { partitionBy: "teamId", orderBy: { column: "score", order: "desc" } })
4906
+ */
4907
+ rank(alias?: string, options?: WindowOptions): this;
4908
+ /**
4909
+ * @description Adds `dense_rank() OVER (...)` to the SELECT list.
4910
+ */
4911
+ denseRank(alias?: string, options?: WindowOptions): this;
4912
+ /**
4913
+ * @description Adds `row_number() OVER (...)` to the SELECT list.
4914
+ */
4915
+ rowNumber(alias?: string, options?: WindowOptions): this;
4916
+ private pushWindow;
4722
4917
  /**
4723
4918
  * @description Clears the SELECT clause
4724
4919
  */
@@ -4834,9 +5029,9 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
4834
5029
  where(cb: (queryBuilder: WhereOnlyQueryBuilder<T>) => void): this;
4835
5030
  where(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4836
5031
  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;
5032
+ where<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
4838
5033
  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;
5034
+ where<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$2, value: ResolveWhereValue<T, K>): this;
4840
5035
  where<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
4841
5036
  /**
4842
5037
  * @description Adds an AND WHERE condition to the query.
@@ -4844,9 +5039,9 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
4844
5039
  andWhere(cb: (queryBuilder: WhereOnlyQueryBuilder<T>) => void): this;
4845
5040
  andWhere(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4846
5041
  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;
5042
+ andWhere<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
4848
5043
  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;
5044
+ andWhere<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$2, value: ResolveWhereValue<T, K>): this;
4850
5045
  andWhere<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
4851
5046
  /**
4852
5047
  * @description Adds an OR WHERE condition to the query.
@@ -4854,57 +5049,80 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
4854
5049
  orWhere(cb: (queryBuilder: WhereOnlyQueryBuilder<T>) => void): this;
4855
5050
  orWhere(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4856
5051
  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;
5052
+ orWhere<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
4858
5053
  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;
5054
+ orWhere<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$2, value: ResolveWhereValue<T, K>): this;
4860
5055
  orWhere<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
4861
5056
  /**
4862
5057
  * @description Adds a WHERE condition comparing two columns.
4863
5058
  */
4864
5059
  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;
5060
+ whereColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, referenceColumn: ModelKey<T>): this;
4866
5061
  whereColumn(column: `${string}.${string}`, referenceColumn: `${string}.${string}`): this;
4867
- whereColumn(column: `${string}.${string}`, operator: BinaryOperatorType$1, referenceColumn: `${string}.${string}`): this;
5062
+ whereColumn(column: `${string}.${string}`, operator: BinaryOperatorType$2, referenceColumn: `${string}.${string}`): this;
4868
5063
  /**
4869
5064
  * @description Adds an AND WHERE condition comparing two columns.
4870
5065
  */
4871
5066
  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;
5067
+ andWhereColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, referenceColumn: ModelKey<T>): this;
4873
5068
  andWhereColumn(column: `${string}.${string}`, referenceColumn: `${string}.${string}`): this;
4874
- andWhereColumn(column: `${string}.${string}`, operator: BinaryOperatorType$1, referenceColumn: `${string}.${string}`): this;
5069
+ andWhereColumn(column: `${string}.${string}`, operator: BinaryOperatorType$2, referenceColumn: `${string}.${string}`): this;
4875
5070
  /**
4876
5071
  * @description Adds an OR WHERE condition comparing two columns.
4877
5072
  */
4878
5073
  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;
5074
+ orWhereColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, referenceColumn: ModelKey<T>): this;
4880
5075
  orWhereColumn(column: `${string}.${string}`, referenceColumn: `${string}.${string}`): this;
4881
- orWhereColumn(column: `${string}.${string}`, operator: BinaryOperatorType$1, referenceColumn: `${string}.${string}`): this;
5076
+ orWhereColumn(column: `${string}.${string}`, operator: BinaryOperatorType$2, referenceColumn: `${string}.${string}`): this;
5077
+ /**
5078
+ * @description Adds a WHERE condition comparing two columns with a negated
5079
+ * comparison, i.e. `column != referenceColumn` (or `NOT (column op referenceColumn)`).
5080
+ */
5081
+ whereNotColumn<K extends ModelKey<T>>(column: K, referenceColumn: ModelKey<T>): this;
5082
+ whereNotColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, referenceColumn: ModelKey<T>): this;
5083
+ whereNotColumn(column: `${string}.${string}`, referenceColumn: `${string}.${string}`): this;
5084
+ whereNotColumn(column: `${string}.${string}`, operator: BinaryOperatorType$2, referenceColumn: `${string}.${string}`): this;
5085
+ /**
5086
+ * @description Adds an AND WHERE condition comparing two columns with a negated comparison.
5087
+ */
5088
+ andWhereNotColumn<K extends ModelKey<T>>(column: K, referenceColumn: ModelKey<T>): this;
5089
+ andWhereNotColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, referenceColumn: ModelKey<T>): this;
5090
+ andWhereNotColumn(column: `${string}.${string}`, referenceColumn: `${string}.${string}`): this;
5091
+ andWhereNotColumn(column: `${string}.${string}`, operator: BinaryOperatorType$2, referenceColumn: `${string}.${string}`): this;
5092
+ /**
5093
+ * @description Adds an OR WHERE condition comparing two columns with a negated comparison.
5094
+ */
5095
+ orWhereNotColumn<K extends ModelKey<T>>(column: K, referenceColumn: ModelKey<T>): this;
5096
+ orWhereNotColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, referenceColumn: ModelKey<T>): this;
5097
+ orWhereNotColumn(column: `${string}.${string}`, referenceColumn: `${string}.${string}`): this;
5098
+ orWhereNotColumn(column: `${string}.${string}`, operator: BinaryOperatorType$2, referenceColumn: `${string}.${string}`): this;
5099
+ private pushNotColumnWhere;
4882
5100
  /**
4883
5101
  * @description Adds a negated WHERE condition to the query.
4884
5102
  */
4885
5103
  whereNot(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4886
5104
  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;
5105
+ whereNot<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
4888
5106
  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;
5107
+ whereNot<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$2, value: ResolveWhereValue<T, K>): this;
4890
5108
  whereNot<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
4891
5109
  /**
4892
5110
  * @description Adds a negated AND WHERE condition to the query.
4893
5111
  */
4894
5112
  andWhereNot(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4895
5113
  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;
5114
+ andWhereNot<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
4897
5115
  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;
5116
+ andWhereNot<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$2, value: ResolveWhereValue<T, K>): this;
4899
5117
  andWhereNot<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
4900
5118
  /**
4901
5119
  * @description Adds a negated OR WHERE condition to the query.
4902
5120
  */
4903
5121
  orWhereNot(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4904
5122
  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;
5123
+ orWhereNot<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
4906
5124
  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;
5125
+ orWhereNot<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$2, value: ResolveWhereValue<T, K>): this;
4908
5126
  orWhereNot<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
4909
5127
  /**
4910
5128
  * @description Adds a WHERE BETWEEN condition to the query.
@@ -5150,24 +5368,24 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
5150
5368
  * @description Adds a HAVING condition to the query.
5151
5369
  */
5152
5370
  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;
5371
+ having<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
5154
5372
  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;
5373
+ having<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$2, value: ResolveWhereValue<T, K>): this;
5156
5374
  /**
5157
5375
  * @description Adds an AND HAVING condition to the query.
5158
5376
  */
5159
5377
  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;
5378
+ andHaving<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
5161
5379
  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;
5380
+ andHaving<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$2, value: ResolveWhereValue<T, K>): this;
5381
+ andHaving(column: ModelKey<T>, operator: BinaryOperatorType$2, value: any): this;
5164
5382
  /**
5165
5383
  * @description Adds an OR HAVING condition to the query.
5166
5384
  */
5167
5385
  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;
5386
+ orHaving<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
5169
5387
  orHaving(column: `${string}.${string}`, value: any): this;
5170
- orHaving(column: `${string}.${string}`, operator: BinaryOperatorType$1, value: any): this;
5388
+ orHaving(column: `${string}.${string}`, operator: BinaryOperatorType$2, value: any): this;
5171
5389
  /**
5172
5390
  * @description Adds a raw HAVING condition to the query.
5173
5391
  */
@@ -5180,6 +5398,63 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
5180
5398
  * @description Adds a raw OR HAVING condition to the query.
5181
5399
  */
5182
5400
  orHavingRaw(query: string): this;
5401
+ /**
5402
+ * @description Adds a HAVING IS NULL condition.
5403
+ */
5404
+ havingNull(column: ModelKey<T> | SelectableColumn$1<string>): this;
5405
+ andHavingNull(column: ModelKey<T> | SelectableColumn$1<string>): this;
5406
+ orHavingNull(column: ModelKey<T> | SelectableColumn$1<string>): this;
5407
+ /**
5408
+ * @description Adds a HAVING IS NOT NULL condition.
5409
+ */
5410
+ havingNotNull(column: ModelKey<T> | SelectableColumn$1<string>): this;
5411
+ andHavingNotNull(column: ModelKey<T> | SelectableColumn$1<string>): this;
5412
+ orHavingNotNull(column: ModelKey<T> | SelectableColumn$1<string>): this;
5413
+ /**
5414
+ * @description Adds a HAVING IN condition; accepts values or a subquery.
5415
+ */
5416
+ havingIn(column: ModelKey<T> | SelectableColumn$1<string>, values: BaseValues$2[] | QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
5417
+ andHavingIn(column: ModelKey<T> | SelectableColumn$1<string>, values: BaseValues$2[] | QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
5418
+ orHavingIn(column: ModelKey<T> | SelectableColumn$1<string>, values: BaseValues$2[] | QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
5419
+ /**
5420
+ * @description Adds a HAVING NOT IN condition; accepts values or a subquery.
5421
+ */
5422
+ havingNotIn(column: ModelKey<T> | SelectableColumn$1<string>, values: BaseValues$2[] | QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
5423
+ andHavingNotIn(column: ModelKey<T> | SelectableColumn$1<string>, values: BaseValues$2[] | QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
5424
+ orHavingNotIn(column: ModelKey<T> | SelectableColumn$1<string>, values: BaseValues$2[] | QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
5425
+ /**
5426
+ * @description Adds a HAVING BETWEEN condition.
5427
+ */
5428
+ havingBetween(column: ModelKey<T> | SelectableColumn$1<string>, range: [BaseValues$2, BaseValues$2]): this;
5429
+ andHavingBetween(column: ModelKey<T> | SelectableColumn$1<string>, range: [BaseValues$2, BaseValues$2]): this;
5430
+ orHavingBetween(column: ModelKey<T> | SelectableColumn$1<string>, range: [BaseValues$2, BaseValues$2]): this;
5431
+ /**
5432
+ * @description Adds a HAVING NOT BETWEEN condition.
5433
+ */
5434
+ havingNotBetween(column: ModelKey<T> | SelectableColumn$1<string>, range: [BaseValues$2, BaseValues$2]): this;
5435
+ andHavingNotBetween(column: ModelKey<T> | SelectableColumn$1<string>, range: [BaseValues$2, BaseValues$2]): this;
5436
+ orHavingNotBetween(column: ModelKey<T> | SelectableColumn$1<string>, range: [BaseValues$2, BaseValues$2]): this;
5437
+ /**
5438
+ * @description Adds a HAVING EXISTS condition (subquery).
5439
+ */
5440
+ havingExists(cbOrQueryBuilder: (queryBuilder: QueryBuilder<T>) => void | QueryBuilder<T>): this;
5441
+ andHavingExists(cbOrQueryBuilder: (queryBuilder: QueryBuilder<T>) => void | QueryBuilder<T>): this;
5442
+ orHavingExists(cbOrQueryBuilder: (queryBuilder: QueryBuilder<T>) => void | QueryBuilder<T>): this;
5443
+ /**
5444
+ * @description Adds a HAVING NOT EXISTS condition (subquery).
5445
+ */
5446
+ havingNotExists(cbOrQueryBuilder: (queryBuilder: QueryBuilder<T>) => void | QueryBuilder<T>): this;
5447
+ andHavingNotExists(cbOrQueryBuilder: (queryBuilder: QueryBuilder<T>) => void | QueryBuilder<T>): this;
5448
+ orHavingNotExists(cbOrQueryBuilder: (queryBuilder: QueryBuilder<T>) => void | QueryBuilder<T>): this;
5449
+ /**
5450
+ * @description Wraps a group of HAVING conditions in parentheses.
5451
+ */
5452
+ havingWrapped(cb: (queryBuilder: WhereQueryBuilder<T>) => void): this;
5453
+ andHavingWrapped(cb: (queryBuilder: WhereQueryBuilder<T>) => void): this;
5454
+ orHavingWrapped(cb: (queryBuilder: WhereQueryBuilder<T>) => void): this;
5455
+ private pushHavingIn;
5456
+ private pushHavingExists;
5457
+ private pushHavingGroup;
5183
5458
  private buildSubQuery;
5184
5459
  private andWhereSubQuery;
5185
5460
  private orWhereSubQuery;
@@ -5264,6 +5539,77 @@ declare class JsonQueryBuilder<T extends Model, S extends Record<string, any> =
5264
5539
  * @description Add a raw JSON filter expression (OR).
5265
5540
  */
5266
5541
  orWhereJsonRaw(raw: string, params?: any[]): this;
5542
+ /**
5543
+ * @description Filters records where the JSON column equals an exact JSON object value.
5544
+ */
5545
+ whereJsonObject<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5546
+ /**
5547
+ * @description Filters records where the JSON column equals an exact JSON object value (AND).
5548
+ */
5549
+ andWhereJsonObject<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5550
+ /**
5551
+ * @description Filters records where the JSON column equals an exact JSON object value (OR).
5552
+ */
5553
+ orWhereJsonObject<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5554
+ /**
5555
+ * @description Filters records where the JSON column does NOT equal an exact JSON object value.
5556
+ */
5557
+ whereNotJsonObject<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5558
+ /**
5559
+ * @description Filters records where the JSON column does NOT equal an exact JSON object value (AND).
5560
+ */
5561
+ andWhereNotJsonObject<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5562
+ /**
5563
+ * @description Filters records where the JSON column does NOT equal an exact JSON object value (OR).
5564
+ */
5565
+ orWhereNotJsonObject<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5566
+ /**
5567
+ * @description Compares the value at a JSON path using the given operator.
5568
+ * @example whereJsonPath("meta", "address.city", "=", "Rome")
5569
+ */
5570
+ whereJsonPath<K extends string>(column: K, path: JsonPathInput, operator: BinaryOperatorType$2, value: any): this;
5571
+ /**
5572
+ * @description Compares the value at a JSON path (AND).
5573
+ */
5574
+ andWhereJsonPath<K extends string>(column: K, path: JsonPathInput, operator: BinaryOperatorType$2, value: any): this;
5575
+ /**
5576
+ * @description Compares the value at a JSON path (OR).
5577
+ */
5578
+ orWhereJsonPath<K extends string>(column: K, path: JsonPathInput, operator: BinaryOperatorType$2, value: any): this;
5579
+ /**
5580
+ * @description Filters records where the JSON column is a superset of the value (contains it).
5581
+ */
5582
+ whereJsonSupersetOf<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5583
+ andWhereJsonSupersetOf<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5584
+ orWhereJsonSupersetOf<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5585
+ /**
5586
+ * @description Filters records where the JSON column is NOT a superset of the value.
5587
+ */
5588
+ whereJsonNotSupersetOf<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5589
+ andWhereJsonNotSupersetOf<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5590
+ orWhereJsonNotSupersetOf<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5591
+ /**
5592
+ * @description Filters records where the JSON column is a subset of the value.
5593
+ * @postgres/cockroachdb/mysql/mariadb only
5594
+ */
5595
+ whereJsonSubsetOf<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5596
+ andWhereJsonSubsetOf<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5597
+ orWhereJsonSubsetOf<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5598
+ /**
5599
+ * @description Filters records where the JSON column is NOT a subset of the value.
5600
+ * @postgres/cockroachdb/mysql/mariadb only
5601
+ */
5602
+ whereJsonNotSubsetOf<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5603
+ andWhereJsonNotSubsetOf<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5604
+ orWhereJsonNotSubsetOf<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
5605
+ /**
5606
+ * @description Filters records where the JSON column has none of the given keys.
5607
+ * @postgres/cockroachdb only
5608
+ */
5609
+ whereJsonHasNone<K extends string>(column: K, keys: string[]): this;
5610
+ andWhereJsonHasNone<K extends string>(column: K, keys: string[]): this;
5611
+ orWhereJsonHasNone<K extends string>(column: K, keys: string[]): this;
5612
+ private pushJsonPath;
5267
5613
  }
5268
5614
 
5269
5615
  type PluckReturnType<T extends Model, K extends RawModelKey<T>> = T[StripTablePrefix<K & string> & keyof T] extends infer U ? U[] : never;
@@ -5484,6 +5830,8 @@ interface ExecuteOptions<D extends SqlDataSourceType, M extends Model> {
5484
5830
  sqlLiteOptions?: SqlLiteOptions<M>;
5485
5831
  /** Reserved connection when inside a transaction; pool otherwise */
5486
5832
  connection?: GetConnectionReturnType<D>;
5833
+ /** Aborted when a `timeout(..., { cancel: true })` fires */
5834
+ signal?: AbortSignal;
5487
5835
  }
5488
5836
  /** rawQuery keeps transaction-level SQL flowing through the datasource (observers/logs) */
5489
5837
  type TransactionRawQuery<D extends SqlDataSourceType> = (query: string, params?: unknown[]) => Promise<RawQueryResponseType<D>>;
@@ -6045,7 +6393,7 @@ type WhereColumnValue<T extends Model, K extends ModelKey<T>> = T[StripTablePref
6045
6393
  * For model columns (ModelKey<T>), returns the specific column type.
6046
6394
  * For arbitrary columns (joins, aliases), falls back to BaseValues.
6047
6395
  */
6048
- type ResolveWhereValue<T extends Model, K extends string> = K extends ModelKey<T> ? T[StripTablePrefix<K> & keyof T] | null | SqlFuncNode : BaseValues$1;
6396
+ type ResolveWhereValue<T extends Model, K extends string> = K extends ModelKey<T> ? T[StripTablePrefix<K> & keyof T] | null | SqlFuncNode : BaseValues$2;
6049
6397
  type ModelRelation<T extends Model> = OnlyRelations<T>;
6050
6398
  type OrderByChoices = "asc" | "desc";
6051
6399
  type OrderByType<T extends Model> = {
@@ -7003,37 +7351,37 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
7003
7351
  * @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
7352
  */
7005
7353
  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;
7354
+ havingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$2 | BaseValues$2, maybeValue?: BaseValues$2): this;
7007
7355
  /**
7008
7356
  * @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
7357
  * @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
7358
  */
7011
7359
  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;
7360
+ andHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$2 | BaseValues$2, maybeValue?: BaseValues$2): this;
7013
7361
  /**
7014
7362
  * @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
7363
  * @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
7364
  */
7017
7365
  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;
7366
+ orHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$2 | BaseValues$2, maybeValue?: BaseValues$2): this;
7019
7367
  /**
7020
7368
  * @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
7369
  * @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
7370
  */
7023
7371
  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;
7372
+ notHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$2 | BaseValues$2, maybeValue?: BaseValues$2): this;
7025
7373
  /**
7026
7374
  * @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
7375
  * @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
7376
  */
7029
7377
  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;
7378
+ andNotHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$2 | BaseValues$2, maybeValue?: BaseValues$2): this;
7031
7379
  /**
7032
7380
  * @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
7381
  * @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
7382
  */
7035
7383
  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;
7384
+ orNotHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$2 | BaseValues$2, maybeValue?: BaseValues$2): this;
7037
7385
  /**
7038
7386
  * @description Returns a copy of the query builder instance.
7039
7387
  */
@@ -7085,7 +7433,7 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
7085
7433
  protected getRelatedModelsForRelation(relationQueryBuilder: ModelQueryBuilder<any>, relation: Relation, models: T[]): Promise<SelectedModel<T, ModelWithoutRelations<T>, R>[]>;
7086
7434
  protected getRelatedModelsQueryForRelation(relationQueryBuilder: ModelQueryBuilder<any>, relation: Relation, models: T[]): ModelQueryBuilder<any, any, any, D>;
7087
7435
  protected getFilterValuesFromModelsForRelation(relation: Relation, models: T[]): any[];
7088
- protected applyHavingRelatedFilter(relationQueryBuilder: ModelQueryBuilder<any>, relation: Relation, operator?: BinaryOperatorType$1, value?: BaseValues$1): void;
7436
+ protected applyHavingRelatedFilter(relationQueryBuilder: ModelQueryBuilder<any>, relation: Relation, operator?: BinaryOperatorType$2, value?: BaseValues$2): void;
7089
7437
  }
7090
7438
 
7091
7439
  /**
@@ -8769,7 +9117,7 @@ declare abstract class BaseSeeder {
8769
9117
  abstract run(): Promise<void>;
8770
9118
  }
8771
9119
 
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}`;
9120
+ 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
9121
 
8774
9122
  declare class HysteriaError extends Error {
8775
9123
  code: HysteriaErrorCode;