hysteria-orm 12.0.2 → 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;
@@ -1760,6 +1804,12 @@ declare class AstParser {
1760
1804
  private readonly model;
1761
1805
  constructor(model: typeof Model, dbType: SqlDataSourceType);
1762
1806
  parse(nodes: (QueryNode | null)[], startBindingIndex?: number, isNestedCondition?: boolean): AstParserType;
1807
+ /**
1808
+ * @description Renders a single node through its dialect interpreter. Used for
1809
+ * nodes pulled out of the main loop (optimizer hints) whose position is fixed
1810
+ * by the parser rather than by their place in the node list.
1811
+ */
1812
+ private renderNode;
1763
1813
  /**
1764
1814
  * Map the database type to a common type if shares the same driver (e.g. mysql and mariadb)
1765
1815
  */
@@ -1779,6 +1829,8 @@ declare class FromNode extends QueryNode {
1779
1829
  folder: string;
1780
1830
  file: string;
1781
1831
  alias?: string;
1832
+ /** Schema applied to the table reference (e.g. `public.users`). */
1833
+ schema?: string;
1782
1834
  constructor(table: string | QueryNode | QueryNode[], alias?: string);
1783
1835
  }
1784
1836
 
@@ -1856,6 +1908,18 @@ declare class InterpreterUtils {
1856
1908
  * @description Formats the table name for the database type, idempotent for quoting
1857
1909
  */
1858
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
+ };
1859
1923
  prepareColumns(columns: string[], values: any[], mode?: "insert" | "update", dbType?: SqlDataSourceType): {
1860
1924
  columns: string[];
1861
1925
  values: any[];
@@ -2183,6 +2247,49 @@ declare class DeleteNode extends QueryNode {
2183
2247
  constructor(fromNode: FromNode, isRawValue?: boolean);
2184
2248
  }
2185
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
+
2186
2293
  declare class InsertNode extends QueryNode {
2187
2294
  fromNode: FromNode;
2188
2295
  records: Record<string, any>[];
@@ -2246,6 +2353,33 @@ declare class UpdateNode extends QueryNode {
2246
2353
  constructor(fromNode: FromNode, columns?: string[], values?: (any | RawNode | SqlFuncNode)[], isRawValue?: boolean);
2247
2354
  }
2248
2355
 
2356
+ /**
2357
+ * PostgreSQL / CockroachDB: `-- line` or `/* block *\/`.
2358
+ */
2359
+ type PgComment = `--${string}` | `/*${string}*/`;
2360
+ /**
2361
+ * SQLite: `-- line` or `/* block *\/`.
2362
+ */
2363
+ type SqliteComment = `--${string}` | `/*${string}*/`;
2364
+ /**
2365
+ * SQL Server: `-- line` or `/* block *\/`.
2366
+ */
2367
+ type MssqlComment = `--${string}` | `/*${string}*/`;
2368
+ /**
2369
+ * MySQL / MariaDB: `-- line` (whitespace required after `--`), `# line`,
2370
+ * `/* block *\/` or `/*! executable *\/`.
2371
+ */
2372
+ type MySqlComment = `-- ${string}` | `#${string}` | `/*${string}*/` | `/*!${string}*/`;
2373
+ /**
2374
+ * A native SQL comment literal valid for the given dialect.
2375
+ */
2376
+ type SqlComment<D extends SqlDataSourceType> = D extends "mysql" | "mariadb" ? MySqlComment : D extends "postgres" | "cockroachdb" ? PgComment : D extends "sqlite" ? SqliteComment : D extends "mssql" ? MssqlComment : string;
2377
+ /**
2378
+ * An optimizer hint literal. Only MySQL/MariaDB consume `/*+ ... *\/`; on every
2379
+ * other dialect `hintComment()` is not callable.
2380
+ */
2381
+ type SqlHint<D extends SqlDataSourceType> = D extends "mysql" | "mariadb" ? `/*+${string}*/` : never;
2382
+
2249
2383
  /**
2250
2384
  * @description The most basic class for all models for both SQL and NoSQL databases
2251
2385
  * @internal Not meant to be used outside of the library
@@ -2773,12 +2907,14 @@ type SoftDeleteOptions<T> = {
2773
2907
  interface SubQueryable {
2774
2908
  extractQueryNodes(): QueryNode[];
2775
2909
  }
2776
- declare class QueryBuilder<T extends Model = any, S extends Record<string, any> = Record<string, any>> extends JsonQueryBuilder<T, S> implements SubQueryable {
2910
+ declare class QueryBuilder<T extends Model = any, S extends Record<string, any> = Record<string, any>, D extends SqlDataSourceType = SqlDataSourceType> extends JsonQueryBuilder<T, S> implements SubQueryable {
2777
2911
  model: typeof Model;
2778
2912
  protected astParser: AstParser;
2779
2913
  protected unionNodes: UnionNode[];
2780
2914
  protected withNodes: WithNode[];
2781
2915
  protected lockQueryNodes: LockNode[];
2916
+ protected comments: string[];
2917
+ protected hints: string[];
2782
2918
  protected isNestedCondition: boolean;
2783
2919
  protected _interpreterUtils: InterpreterUtils | null;
2784
2920
  protected get interpreterUtils(): InterpreterUtils;
@@ -2789,6 +2925,11 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
2789
2925
  protected returningNode: ReturningNode | null;
2790
2926
  protected truncateNode: TruncateNode | null;
2791
2927
  protected replicationMode: ReplicationType | null;
2928
+ protected schemaName?: string;
2929
+ protected queryTimeout?: {
2930
+ ms: number;
2931
+ cancel: boolean;
2932
+ };
2792
2933
  constructor(model: typeof Model, sqlDataSource: SqlDataSource);
2793
2934
  /**
2794
2935
  * @description Sets the replication mode for the query builder
@@ -2811,10 +2952,10 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
2811
2952
  * // user type: { userName: any } | null
2812
2953
  * ```
2813
2954
  */
2814
- select<const Columns extends readonly Selectable[]>(...columns: Columns): QueryBuilder<T, ComposeBuildRawSelect<S, Columns>>;
2955
+ select<const Columns extends readonly Selectable[]>(...columns: Columns): QueryBuilder<T, ComposeBuildRawSelect<S, Columns>, D>;
2815
2956
  select<ValueType = any, Alias extends string = string>(cbOrQueryBuilder: ((subQuery: QueryBuilder<T>) => void | SubQueryable) | QueryBuilder<any>, alias: Alias): QueryBuilder<T, ComposeRawSelect<S, {
2816
2957
  [K in Alias]: ValueType;
2817
- }>>;
2958
+ }>, D>;
2818
2959
  /**
2819
2960
  * @description Adds a raw SELECT statement to the query with type safety.
2820
2961
  * @description Use the generic parameter to specify the type of the selected columns.
@@ -2826,11 +2967,11 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
2826
2967
  * // result type: { total: number } | null
2827
2968
  * ```
2828
2969
  */
2829
- selectRaw<Added extends Record<string, any> = Record<string, any>>(statement: string): QueryBuilder<T, ComposeRawSelect<S, Added>>;
2970
+ selectRaw<Added extends Record<string, any> = Record<string, any>>(statement: string): QueryBuilder<T, ComposeRawSelect<S, Added>, D>;
2830
2971
  /**
2831
2972
  * @description Clears the SELECT clause and resets type to default
2832
2973
  */
2833
- clearSelect(): QueryBuilder<T, Record<string, any>>;
2974
+ clearSelect(): QueryBuilder<T, Record<string, any>, D>;
2834
2975
  /**
2835
2976
  * @description Selects a SQL function applied to a column with a typed alias.
2836
2977
  * @description Provides intellisense for common SQL functions while accepting any custom function.
@@ -2848,22 +2989,22 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
2848
2989
  */
2849
2990
  selectFunc<F extends SqlFunction, Alias extends string>(sqlFunc: F, column: string, alias: Alias): QueryBuilder<T, ComposeRawSelect<S, {
2850
2991
  [K in Alias]: SqlFunctionReturnType<F>;
2851
- }>>;
2992
+ }>, D>;
2852
2993
  selectJson<ValueType = any, Alias extends string = string>(column: ModelKey<T> | string, path: JsonPathInput, alias: Alias): QueryBuilder<T, ComposeRawSelect<S, {
2853
2994
  [K in Alias]: ValueType;
2854
- }>>;
2995
+ }>, D>;
2855
2996
  selectJsonText<ValueType = string, Alias extends string = string>(column: ModelKey<T> | string, path: JsonPathInput, alias: Alias): QueryBuilder<T, ComposeRawSelect<S, {
2856
2997
  [K in Alias]: ValueType;
2857
- }>>;
2998
+ }>, D>;
2858
2999
  selectJsonArrayLength<Alias extends string = string>(column: ModelKey<T> | string, path: JsonPathInput, alias: Alias): QueryBuilder<T, ComposeRawSelect<S, {
2859
3000
  [K in Alias]: number;
2860
- }>>;
3001
+ }>, D>;
2861
3002
  selectJsonKeys<Alias extends string = string>(column: ModelKey<T> | string, path: JsonPathInput, alias: Alias): QueryBuilder<T, ComposeRawSelect<S, {
2862
3003
  [K in Alias]: string[];
2863
- }>>;
3004
+ }>, D>;
2864
3005
  selectJsonRaw<ValueType = any, Alias extends string = string>(raw: string, alias: Alias): QueryBuilder<T, ComposeRawSelect<S, {
2865
3006
  [K in Alias]: ValueType;
2866
- }>>;
3007
+ }>, D>;
2867
3008
  /**
2868
3009
  * @description Executes the query and returns true if the query returns at least one result, false otherwise.
2869
3010
  */
@@ -2952,6 +3093,69 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
2952
3093
  skipLocked?: boolean;
2953
3094
  noWait?: boolean;
2954
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;
3128
+ /**
3129
+ * @description Prepends a native SQL comment to the select statement, in the
3130
+ * syntax of the active dialect (e.g. `-- line`, `/* block *\/`; MySQL adds
3131
+ * `# line` and `/*! executable *\/`). Select-only. Stackable — each call adds
3132
+ * its own comment.
3133
+ * @throws If the value is not a valid comment for the dialect
3134
+ */
3135
+ comment(comment: SqlComment<D>): this;
3136
+ /**
3137
+ * @description Adds an optimizer hint (`/*+ ... *\/`) immediately after the
3138
+ * SELECT keyword, where MySQL/MariaDB read it. Select-only.
3139
+ * @description Only callable when the dialect is MySQL/MariaDB; stackable —
3140
+ * repeated calls join into a single hint comment.
3141
+ * @throws If the value is not a valid optimizer hint
3142
+ */
3143
+ hintComment(hint: SqlHint<D>): this;
3144
+ /**
3145
+ * @description Removes any comment added with `comment()`
3146
+ */
3147
+ clearComment(): this;
3148
+ /**
3149
+ * @description Removes any hint added with `hintComment()`
3150
+ */
3151
+ clearHintComment(): this;
3152
+ /**
3153
+ * @description Comments are interpolated into the SQL verbatim, so a value that
3154
+ * escapes the comment — a newline inside a line comment, or a nested `*\/` in a
3155
+ * block comment — would let the caller inject arbitrary SQL. A `?` is rejected
3156
+ * because the driver reads it as a bind placeholder even inside a comment.
3157
+ */
3158
+ private assertValidSqlComment;
2955
3159
  /**
2956
3160
  * @description Adds a UNION to the query.
2957
3161
  */
@@ -2963,6 +3167,17 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
2963
3167
  unionAll(query: string, bindings?: any[]): this;
2964
3168
  unionAll(cb: UnionCallBack<T>): this;
2965
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;
2966
3181
  /**
2967
3182
  * @description Increments the value of a column by a given amount
2968
3183
  * @typeSafe - In typescript, only numeric columns of the model will be accepted if using a Model
@@ -3013,6 +3228,12 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3013
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.
3014
3229
  */
3015
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>;
3016
3237
  /**
3017
3238
  * @description Executes the query and retrieves multiple paginated results.
3018
3239
  * @description Overrides the limit and offset clauses in order to paginate the results.
@@ -3024,6 +3245,16 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3024
3245
  */
3025
3246
  table<S extends string>(table: TableFormat<S>, maybeAlias?: string): this;
3026
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;
3027
3258
  /**
3028
3259
  * @description Adds a CTE to the query using a callback to build the subquery.
3029
3260
  */
@@ -3039,6 +3270,12 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3039
3270
  * @throws HysteriaError if the database type is not postgres or cockroachdb
3040
3271
  */
3041
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;
3042
3279
  /**
3043
3280
  * @description Insert record into a table, you can use raw statements in the data object for literal references to other columns
3044
3281
  * @param returning - The columns to return from the query, only supported by postgres and cockroachdb - default is "*"
@@ -3134,11 +3371,11 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3134
3371
  /**
3135
3372
  * @description Returns a deep clone of the query builder instance.
3136
3373
  */
3137
- clone(): QueryBuilder<T, S>;
3374
+ clone(): QueryBuilder<T, S, D>;
3138
3375
  /**
3139
3376
  * @description Gives a fresh instance of the query builder
3140
3377
  */
3141
- clear(): QueryBuilder<T, Record<string, any>>;
3378
+ clear(): QueryBuilder<T, Record<string, any>, D>;
3142
3379
  /**
3143
3380
  * @description Removes the lock query
3144
3381
  */
@@ -3172,49 +3409,6 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3172
3409
  protected execSqlWithSlaveHandling<R>(mode: "read" | "write", operation: (dataSource: SqlDataSource) => Promise<R>): Promise<R>;
3173
3410
  }
3174
3411
 
3175
- type TableColumnInfo = {
3176
- name: string;
3177
- dataType: string;
3178
- isNullable: boolean;
3179
- defaultValue: string | number | boolean | null;
3180
- length?: number | null;
3181
- precision?: number | null;
3182
- scale?: number | null;
3183
- withTimezone?: boolean | null;
3184
- enumValues?: string[] | null;
3185
- unsigned?: boolean | null;
3186
- zerofill?: boolean | null;
3187
- stringMode?: boolean | null;
3188
- };
3189
- type TableIndexInfo = {
3190
- name: string;
3191
- columns: string[];
3192
- isUnique: boolean;
3193
- };
3194
- type TablePrimaryKeyInfo = {
3195
- name?: string;
3196
- columns: string[];
3197
- };
3198
- type TableCheckConstraintInfo = {
3199
- name: string;
3200
- expression: string;
3201
- };
3202
- type TableSchemaInfo = {
3203
- columns: TableColumnInfo[];
3204
- indexes: TableIndexInfo[];
3205
- foreignKeys: TableForeignKeyInfo[];
3206
- primaryKey?: TablePrimaryKeyInfo;
3207
- checkConstraints: TableCheckConstraintInfo[];
3208
- };
3209
- type TableForeignKeyInfo = {
3210
- name?: string;
3211
- columns: string[];
3212
- referencedTable: string;
3213
- referencedColumns: string[];
3214
- onDelete?: string | null;
3215
- onUpdate?: string | null;
3216
- };
3217
-
3218
3412
  type Returning = "rows" | "affectedRows" | "raw";
3219
3413
  /**
3220
3414
  * @description Maps a SqlDataSourceType to the raw driver response type
@@ -3570,7 +3764,12 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
3570
3764
  * // rows is typed as Record<string, any>[]
3571
3765
  * ```
3572
3766
  */
3573
- from<S extends string>(table: TableFormat<S>, options?: RawModelOptions): QueryBuilder;
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>;
3574
3773
  /**
3575
3774
  * @description Returns a SchemaBuilder instance for DDL operations
3576
3775
  * @description The builder will execute queries when awaited or when .execute() is called
@@ -3685,6 +3884,20 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
3685
3884
  * ```
3686
3885
  */
3687
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;
3688
3901
  /**
3689
3902
  * @description Retrieves information from the database for the given table
3690
3903
  */
@@ -3871,11 +4084,13 @@ declare class SelectNode extends QueryNode {
3871
4084
  column: string | QueryNode | QueryNode[];
3872
4085
  alias?: string;
3873
4086
  sqlFunction?: string;
4087
+ /** Renders the aggregate as `fn(DISTINCT col)` (e.g. count/sum/avg). */
4088
+ distinct?: boolean;
3874
4089
  chainsWith: string;
3875
4090
  canKeywordBeSeenMultipleTimes: boolean;
3876
4091
  folder: string;
3877
4092
  file: string;
3878
- 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);
3879
4094
  }
3880
4095
 
3881
4096
  declare class JoinNode extends QueryNode {
@@ -3893,6 +4108,10 @@ declare class JoinNode extends QueryNode {
3893
4108
  file: string;
3894
4109
  type: "inner" | "left" | "right" | "full" | "cross" | "natural";
3895
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;
3896
4115
  constructor(table: string, left: string, right: string, type: "inner" | "left" | "right" | "full" | "cross" | "natural" | undefined, on: {
3897
4116
  left?: string;
3898
4117
  right?: string;
@@ -4311,60 +4530,60 @@ declare class JoinOnQueryBuilder {
4311
4530
  /**
4312
4531
  * @description Adds a WHERE condition to the query.
4313
4532
  */
4314
- 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;
4315
4534
  where(cb: (queryBuilder: JoinOnQueryBuilder) => void): this;
4316
- where(column: SelectableColumn$1<string>, value: BaseValues$1): this;
4535
+ where(column: SelectableColumn$1<string>, value: BaseValues$2): this;
4317
4536
  /**
4318
4537
  * @description Adds an AND WHERE condition to the query.
4319
4538
  */
4320
- andWhere(column: SelectableColumn$1<string>, operator: BinaryOperatorType$1, value: BaseValues$1): this;
4321
- 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;
4322
4541
  andWhere(cb: (queryBuilder: JoinOnQueryBuilder) => void): this;
4323
4542
  /**
4324
4543
  * @description Adds an OR WHERE condition to the query.
4325
4544
  */
4326
- orWhere(column: SelectableColumn$1<string>, operator: BinaryOperatorType$1, value: BaseValues$1): this;
4327
- 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;
4328
4547
  orWhere(cb: (queryBuilder: JoinOnQueryBuilder) => void): this;
4329
4548
  /**
4330
4549
  * @description Adds a negated WHERE condition to the query.
4331
4550
  */
4332
- whereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$1, value: BaseValues$1): this;
4333
- 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;
4334
4553
  /**
4335
4554
  * @description Adds a negated AND WHERE condition to the query.
4336
4555
  */
4337
- andWhereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$1, value: BaseValues$1): this;
4338
- 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;
4339
4558
  /**
4340
4559
  * @description Adds a negated OR WHERE condition to the query.
4341
4560
  */
4342
- orWhereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$1, value: BaseValues$1): this;
4343
- 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;
4344
4563
  /**
4345
4564
  * @description Adds a WHERE BETWEEN condition to the query.
4346
4565
  */
4347
- 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;
4348
4567
  /**
4349
4568
  * @description Adds an AND WHERE BETWEEN condition to the query.
4350
4569
  */
4351
- 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;
4352
4571
  /**
4353
4572
  * @description Adds an OR WHERE BETWEEN condition to the query.
4354
4573
  */
4355
- 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;
4356
4575
  /**
4357
4576
  * @description Adds a WHERE NOT BETWEEN condition to the query.
4358
4577
  */
4359
- 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;
4360
4579
  /**
4361
4580
  * @description Adds an AND WHERE NOT BETWEEN condition to the query.
4362
4581
  */
4363
- 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;
4364
4583
  /**
4365
4584
  * @description Adds an OR WHERE NOT BETWEEN condition to the query.
4366
4585
  */
4367
- 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;
4368
4587
  /**
4369
4588
  * @description Adds a WHERE LIKE condition to the query.
4370
4589
  */
@@ -4416,27 +4635,27 @@ declare class JoinOnQueryBuilder {
4416
4635
  /**
4417
4636
  * @description Adds a WHERE IN condition to the query.
4418
4637
  */
4419
- whereIn(column: SelectableColumn$1<string>, values: BaseValues$1[]): this;
4638
+ whereIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
4420
4639
  /**
4421
4640
  * @description Adds an AND WHERE IN condition to the query.
4422
4641
  */
4423
- andWhereIn(column: SelectableColumn$1<string>, values: BaseValues$1[]): this;
4642
+ andWhereIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
4424
4643
  /**
4425
4644
  * @description Adds an OR WHERE IN condition to the query.
4426
4645
  */
4427
- orWhereIn(column: SelectableColumn$1<string>, values: BaseValues$1[]): this;
4646
+ orWhereIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
4428
4647
  /**
4429
4648
  * @description Adds a WHERE NOT IN condition to the query.
4430
4649
  */
4431
- whereNotIn(column: SelectableColumn$1<string>, values: BaseValues$1[]): this;
4650
+ whereNotIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
4432
4651
  /**
4433
4652
  * @description Adds an AND WHERE NOT IN condition to the query.
4434
4653
  */
4435
- andWhereNotIn(column: SelectableColumn$1<string>, values: BaseValues$1[]): this;
4654
+ andWhereNotIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
4436
4655
  /**
4437
4656
  * @description Adds an OR WHERE NOT IN condition to the query.
4438
4657
  */
4439
- orWhereNotIn(column: SelectableColumn$1<string>, values: BaseValues$1[]): this;
4658
+ orWhereNotIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
4440
4659
  /**
4441
4660
  * @description Adds a WHERE NULL condition to the query.
4442
4661
  */
@@ -4500,15 +4719,15 @@ declare class JoinOnQueryBuilder {
4500
4719
  /**
4501
4720
  * @description Adds a raw WHERE condition to the query.
4502
4721
  */
4503
- whereRaw(sql: string, bindings?: BaseValues$1[]): this;
4722
+ whereRaw(sql: string, bindings?: BaseValues$2[]): this;
4504
4723
  /**
4505
4724
  * @description Adds an AND raw WHERE condition to the query.
4506
4725
  */
4507
- andWhereRaw(sql: string, bindings?: BaseValues$1[]): this;
4726
+ andWhereRaw(sql: string, bindings?: BaseValues$2[]): this;
4508
4727
  /**
4509
4728
  * @description Adds an OR raw WHERE condition to the query.
4510
4729
  */
4511
- orWhereRaw(sql: string, bindings?: BaseValues$1[]): this;
4730
+ orWhereRaw(sql: string, bindings?: BaseValues$2[]): this;
4512
4731
  }
4513
4732
 
4514
4733
  /**
@@ -4542,6 +4761,17 @@ declare abstract class JoinQueryBuilder<T extends Model, S extends Record<string
4542
4761
  * @description Join a table with the current model, join clause is not necessary and will be added automatically
4543
4762
  */
4544
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;
4545
4775
  /**
4546
4776
  * @description Join a table with the current model, join clause is not necessary and will be added automatically
4547
4777
  */
@@ -4553,13 +4783,14 @@ declare abstract class JoinQueryBuilder<T extends Model, S extends Record<string
4553
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`
4554
4784
  * @param operator - The comparison operator to use in the ON clause (default: "=")
4555
4785
  */
4556
- innerJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$1): this;
4557
- innerJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$1): this;
4558
- innerJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator?: BinaryOperatorType$1): this;
4559
- innerJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn?: ModelKey<T>, operator?: BinaryOperatorType$1): this;
4560
- 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;
4561
4792
  innerJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, callback: JoinOnCallback): this;
4562
- 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;
4563
4794
  innerJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, callback: JoinOnCallback): this;
4564
4795
  /**
4565
4796
  * @description Join a table with the current model
@@ -4568,13 +4799,14 @@ declare abstract class JoinQueryBuilder<T extends Model, S extends Record<string
4568
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`
4569
4800
  * @param operator - The comparison operator to use in the ON clause (default: "=")
4570
4801
  */
4571
- join(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$1): this;
4572
- join(relationTable: string, referencingColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$1): this;
4573
- join<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator?: BinaryOperatorType$1): this;
4574
- join<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn?: ModelKey<T>, operator?: BinaryOperatorType$1): this;
4575
- 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;
4576
4808
  join(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, callback: JoinOnCallback): this;
4577
- 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;
4578
4810
  join<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, callback: JoinOnCallback): this;
4579
4811
  /**
4580
4812
  * @description Join a table with the current model
@@ -4583,13 +4815,14 @@ declare abstract class JoinQueryBuilder<T extends Model, S extends Record<string
4583
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`
4584
4816
  * @param operator - The comparison operator to use in the ON clause (default: "=")
4585
4817
  */
4586
- leftJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$1): this;
4587
- leftJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$1): this;
4588
- leftJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator?: BinaryOperatorType$1): this;
4589
- leftJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn?: ModelKey<T>, operator?: BinaryOperatorType$1): this;
4590
- 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;
4591
4824
  leftJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, callback: JoinOnCallback): this;
4592
- 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;
4593
4826
  leftJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, callback: JoinOnCallback): this;
4594
4827
  /**
4595
4828
  * @description Join a table with the current model
@@ -4598,10 +4831,11 @@ declare abstract class JoinQueryBuilder<T extends Model, S extends Record<string
4598
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
4599
4832
  * @param operator - The comparison operator to use in the ON clause (default: "=")
4600
4833
  */
4601
- rightJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$1): this;
4602
- rightJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$1): this;
4603
- rightJoin<R extends AnyModelConstructor>(relationTable: string | R, referencingColumnOrPrimaryColumn: ModelKey<InstanceType<R>> | JoinableColumn | ModelKey<T>, primaryColumn?: JoinableColumn | ModelKey<T>, operator?: BinaryOperatorType$1): this;
4604
- 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;
4605
4839
  rightJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, callback: JoinOnCallback): this;
4606
4840
  /**
4607
4841
  * @description Perform a FULL OUTER JOIN with another table
@@ -4610,10 +4844,10 @@ declare abstract class JoinQueryBuilder<T extends Model, S extends Record<string
4610
4844
  * @param primaryColumn - The primary column of the current model
4611
4845
  * @param operator - The comparison operator to use in the ON clause (default: "=")
4612
4846
  */
4613
- fullJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$1): this;
4614
- fullJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$1): this;
4615
- fullJoin<R extends AnyModelConstructor>(relationTable: string | R, referencingColumnOrPrimaryColumn: ModelKey<InstanceType<R>> | JoinableColumn | ModelKey<T>, primaryColumn?: JoinableColumn | ModelKey<T>, operator?: BinaryOperatorType$1): this;
4616
- 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;
4617
4851
  fullJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, callback: JoinOnCallback): this;
4618
4852
  }
4619
4853
 
@@ -4653,6 +4887,33 @@ declare class SelectQueryBuilder<T extends Model, S extends Record<string, any>
4653
4887
  * .selectFunc("custom_fn", "column", "result")
4654
4888
  */
4655
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;
4656
4917
  /**
4657
4918
  * @description Clears the SELECT clause
4658
4919
  */
@@ -4768,9 +5029,9 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
4768
5029
  where(cb: (queryBuilder: WhereOnlyQueryBuilder<T>) => void): this;
4769
5030
  where(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4770
5031
  where(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4771
- 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;
4772
5033
  where<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
4773
- 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;
4774
5035
  where<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
4775
5036
  /**
4776
5037
  * @description Adds an AND WHERE condition to the query.
@@ -4778,9 +5039,9 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
4778
5039
  andWhere(cb: (queryBuilder: WhereOnlyQueryBuilder<T>) => void): this;
4779
5040
  andWhere(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4780
5041
  andWhere(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4781
- 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;
4782
5043
  andWhere<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
4783
- 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;
4784
5045
  andWhere<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
4785
5046
  /**
4786
5047
  * @description Adds an OR WHERE condition to the query.
@@ -4788,57 +5049,80 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
4788
5049
  orWhere(cb: (queryBuilder: WhereOnlyQueryBuilder<T>) => void): this;
4789
5050
  orWhere(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4790
5051
  orWhere(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4791
- 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;
4792
5053
  orWhere<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
4793
- 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;
4794
5055
  orWhere<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
4795
5056
  /**
4796
5057
  * @description Adds a WHERE condition comparing two columns.
4797
5058
  */
4798
5059
  whereColumn<K extends ModelKey<T>>(column: K, referenceColumn: ModelKey<T>): this;
4799
- 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;
4800
5061
  whereColumn(column: `${string}.${string}`, referenceColumn: `${string}.${string}`): this;
4801
- whereColumn(column: `${string}.${string}`, operator: BinaryOperatorType$1, referenceColumn: `${string}.${string}`): this;
5062
+ whereColumn(column: `${string}.${string}`, operator: BinaryOperatorType$2, referenceColumn: `${string}.${string}`): this;
4802
5063
  /**
4803
5064
  * @description Adds an AND WHERE condition comparing two columns.
4804
5065
  */
4805
5066
  andWhereColumn<K extends ModelKey<T>>(column: K, referenceColumn: ModelKey<T>): this;
4806
- 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;
4807
5068
  andWhereColumn(column: `${string}.${string}`, referenceColumn: `${string}.${string}`): this;
4808
- andWhereColumn(column: `${string}.${string}`, operator: BinaryOperatorType$1, referenceColumn: `${string}.${string}`): this;
5069
+ andWhereColumn(column: `${string}.${string}`, operator: BinaryOperatorType$2, referenceColumn: `${string}.${string}`): this;
4809
5070
  /**
4810
5071
  * @description Adds an OR WHERE condition comparing two columns.
4811
5072
  */
4812
5073
  orWhereColumn<K extends ModelKey<T>>(column: K, referenceColumn: ModelKey<T>): this;
4813
- 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;
4814
5075
  orWhereColumn(column: `${string}.${string}`, referenceColumn: `${string}.${string}`): this;
4815
- 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;
4816
5100
  /**
4817
5101
  * @description Adds a negated WHERE condition to the query.
4818
5102
  */
4819
5103
  whereNot(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4820
5104
  whereNot(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4821
- 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;
4822
5106
  whereNot<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
4823
- 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;
4824
5108
  whereNot<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
4825
5109
  /**
4826
5110
  * @description Adds a negated AND WHERE condition to the query.
4827
5111
  */
4828
5112
  andWhereNot(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4829
5113
  andWhereNot(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4830
- 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;
4831
5115
  andWhereNot<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
4832
- 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;
4833
5117
  andWhereNot<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
4834
5118
  /**
4835
5119
  * @description Adds a negated OR WHERE condition to the query.
4836
5120
  */
4837
5121
  orWhereNot(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4838
5122
  orWhereNot(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4839
- 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;
4840
5124
  orWhereNot<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
4841
- 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;
4842
5126
  orWhereNot<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
4843
5127
  /**
4844
5128
  * @description Adds a WHERE BETWEEN condition to the query.
@@ -5084,24 +5368,24 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
5084
5368
  * @description Adds a HAVING condition to the query.
5085
5369
  */
5086
5370
  having<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
5087
- 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;
5088
5372
  having<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
5089
- 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;
5090
5374
  /**
5091
5375
  * @description Adds an AND HAVING condition to the query.
5092
5376
  */
5093
5377
  andHaving<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
5094
- 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;
5095
5379
  andHaving<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
5096
- andHaving<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$1, value: ResolveWhereValue<T, K>): this;
5097
- 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;
5098
5382
  /**
5099
5383
  * @description Adds an OR HAVING condition to the query.
5100
5384
  */
5101
5385
  orHaving<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
5102
- 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;
5103
5387
  orHaving(column: `${string}.${string}`, value: any): this;
5104
- orHaving(column: `${string}.${string}`, operator: BinaryOperatorType$1, value: any): this;
5388
+ orHaving(column: `${string}.${string}`, operator: BinaryOperatorType$2, value: any): this;
5105
5389
  /**
5106
5390
  * @description Adds a raw HAVING condition to the query.
5107
5391
  */
@@ -5114,6 +5398,63 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
5114
5398
  * @description Adds a raw OR HAVING condition to the query.
5115
5399
  */
5116
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;
5117
5458
  private buildSubQuery;
5118
5459
  private andWhereSubQuery;
5119
5460
  private orWhereSubQuery;
@@ -5198,6 +5539,77 @@ declare class JsonQueryBuilder<T extends Model, S extends Record<string, any> =
5198
5539
  * @description Add a raw JSON filter expression (OR).
5199
5540
  */
5200
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;
5201
5613
  }
5202
5614
 
5203
5615
  type PluckReturnType<T extends Model, K extends RawModelKey<T>> = T[StripTablePrefix<K & string> & keyof T] extends infer U ? U[] : never;
@@ -5418,6 +5830,8 @@ interface ExecuteOptions<D extends SqlDataSourceType, M extends Model> {
5418
5830
  sqlLiteOptions?: SqlLiteOptions<M>;
5419
5831
  /** Reserved connection when inside a transaction; pool otherwise */
5420
5832
  connection?: GetConnectionReturnType<D>;
5833
+ /** Aborted when a `timeout(..., { cancel: true })` fires */
5834
+ signal?: AbortSignal;
5421
5835
  }
5422
5836
  /** rawQuery keeps transaction-level SQL flowing through the datasource (observers/logs) */
5423
5837
  type TransactionRawQuery<D extends SqlDataSourceType> = (query: string, params?: unknown[]) => Promise<RawQueryResponseType<D>>;
@@ -5979,7 +6393,7 @@ type WhereColumnValue<T extends Model, K extends ModelKey<T>> = T[StripTablePref
5979
6393
  * For model columns (ModelKey<T>), returns the specific column type.
5980
6394
  * For arbitrary columns (joins, aliases), falls back to BaseValues.
5981
6395
  */
5982
- 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;
5983
6397
  type ModelRelation<T extends Model> = OnlyRelations<T>;
5984
6398
  type OrderByChoices = "asc" | "desc";
5985
6399
  type OrderByType<T extends Model> = {
@@ -6426,7 +6840,7 @@ type UpdateOptions = {};
6426
6840
  */
6427
6841
  type RelationQueryBuilderType<T extends Model, A extends Record<string, any> = {}, R extends Record<string, any> = {}> = Omit<ModelQueryBuilder<T, A, R>, "increment" | "decrement" | "paginate" | "pluck" | "truncate" | "many" | "one" | "oneOrFail" | "insert" | "insertMany" | "update" | "delete" | "softDelete" | "getSum" | "getAvg" | "getMin" | "getMax" | "getCount" | "getMin" | "getMax" | "getCount">;
6428
6842
 
6429
- declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> = ModelWithoutRelations<T>, R extends Record<string, any> = {}, D extends SqlDataSourceType = SqlDataSourceType> extends QueryBuilder<T, Record<string, any>> {
6843
+ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> = ModelWithoutRelations<T>, R extends Record<string, any> = {}, D extends SqlDataSourceType = SqlDataSourceType> extends QueryBuilder<T, Record<string, any>, D> {
6430
6844
  relation: Relation;
6431
6845
  protected sqlModelManagerUtils: SqlModelManagerUtils<T>;
6432
6846
  protected relationQueryBuilders: ModelQueryBuilder<any>[];
@@ -6621,11 +7035,11 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
6621
7035
  * const users = await sql.from(users).select("*").many();
6622
7036
  * ```
6623
7037
  */
6624
- select<const Columns extends readonly (ModelKey<T> | `${string}.*` | "*" | readonly [ModelKey<T>, string])[]>(...columns: Columns): ModelQueryBuilder<T, ComposeBuildSelect<S, T, Columns extends readonly (string | readonly [string, string])[] ? Columns : readonly (string | readonly [string, string])[]>, R>;
6625
- select<const Columns extends readonly ModelSelectableInput<T>[]>(...columns: Columns): ModelQueryBuilder<T, ComposeBuildSelect<S, T, Columns extends readonly (string | readonly [string, string])[] ? Columns : readonly (string | readonly [string, string])[]>, R>;
7038
+ select<const Columns extends readonly (ModelKey<T> | `${string}.*` | "*" | readonly [ModelKey<T>, string])[]>(...columns: Columns): ModelQueryBuilder<T, ComposeBuildSelect<S, T, Columns extends readonly (string | readonly [string, string])[] ? Columns : readonly (string | readonly [string, string])[]>, R, D>;
7039
+ select<const Columns extends readonly ModelSelectableInput<T>[]>(...columns: Columns): ModelQueryBuilder<T, ComposeBuildSelect<S, T, Columns extends readonly (string | readonly [string, string])[] ? Columns : readonly (string | readonly [string, string])[]>, R, D>;
6626
7040
  select<ValueType = any, Alias extends string = string>(cbOrQueryBuilder: ((subQuery: QueryBuilder<T>) => void | SubQueryable) | QueryBuilder<any, any>, alias: Alias): ModelQueryBuilder<T, ComposeSelect<S, {
6627
7041
  [K in Alias]: ValueType;
6628
- }>, R>;
7042
+ }>, R, D>;
6629
7043
  /**
6630
7044
  * @description Adds a raw SELECT statement with type-safe return type.
6631
7045
  * @description Use the generic parameter to specify the type of the selected columns.
@@ -6645,7 +7059,7 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
6645
7059
  * // users[0] is { id: number, total: number }
6646
7060
  * ```
6647
7061
  */
6648
- selectRaw<Added extends Record<string, any> = Record<string, any>>(statement: string): ModelQueryBuilder<T, ComposeSelect<S, Added>, R>;
7062
+ selectRaw<Added extends Record<string, any> = Record<string, any>>(statement: string): ModelQueryBuilder<T, ComposeSelect<S, Added>, R, D>;
6649
7063
  /**
6650
7064
  * @description Selects a SQL function applied to a column with a typed alias.
6651
7065
  * @description Provides intellisense for common SQL functions while accepting any custom function.
@@ -6669,7 +7083,7 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
6669
7083
  */
6670
7084
  selectFunc<F extends SqlFunction, Alias extends string>(sqlFunc: F, column: ModelKey<T> | "*" | (string & {}), alias: Alias): ModelQueryBuilder<T, ComposeSelect<S, {
6671
7085
  [K in Alias]: SqlFunctionReturnType<F>;
6672
- }>, R>;
7086
+ }>, R, D>;
6673
7087
  /**
6674
7088
  * @description Clears the SELECT clause and resets to default model type
6675
7089
  * @example
@@ -6680,7 +7094,7 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
6680
7094
  * .many();
6681
7095
  * ```
6682
7096
  */
6683
- clearSelect(): ModelQueryBuilder<T, ModelWithoutRelations<T>, R>;
7097
+ clearSelect(): ModelQueryBuilder<T, ModelWithoutRelations<T>, R, D>;
6684
7098
  /**
6685
7099
  * @description Selects a JSON value at the specified path and returns it as JSON.
6686
7100
  * @param column - The column containing JSON data. Accepts model column names (with IDE autocompletion)
@@ -6721,7 +7135,7 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
6721
7135
  */
6722
7136
  selectJson<K extends ModelKey<T> | (string & {}), P extends [K] extends [ModelKey<T>] ? TypedJsonPathInput<ResolveColumnType<T, K & string>> : JsonPathInput, Alias extends string = string>(column: K, path: P, alias: Alias): ModelQueryBuilder<T, ComposeSelect<S, {
6723
7137
  [Q in Alias]: [K] extends [ModelKey<T>] ? P extends string ? ResolveJsonPathType<NonNullable<ResolveColumnType<T, K & string>>, P> extends infer R ? unknown extends R ? any : R : any : any : any;
6724
- }>, R>;
7138
+ }>, R, D>;
6725
7139
  /**
6726
7140
  * @description Selects a JSON value at the specified path and returns it as text.
6727
7141
  * @param column - The column containing JSON data. Accepts model column names (with IDE autocompletion)
@@ -6759,7 +7173,7 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
6759
7173
  */
6760
7174
  selectJsonText<K extends ModelKey<T> | (string & {}), ValueType = string, Alias extends string = string>(column: K, path: K extends ModelKey<T> ? TypedJsonPathInput<ResolveColumnType<T, K & string>> : JsonPathInput, alias: Alias): ModelQueryBuilder<T, ComposeSelect<S, {
6761
7175
  [P in Alias]: ValueType;
6762
- }>, R>;
7176
+ }>, R, D>;
6763
7177
  /**
6764
7178
  * @description Selects the length of a JSON array at the specified path.
6765
7179
  * @param column - The column containing JSON array data. Accepts model column names (with IDE autocompletion)
@@ -6801,7 +7215,7 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
6801
7215
  */
6802
7216
  selectJsonArrayLength<K extends ModelKey<T> | (string & {}), ValueType = number, Alias extends string = string>(column: K, path: K extends ModelKey<T> ? TypedJsonPathInput<ResolveColumnType<T, K & string>> : JsonPathInput, alias: Alias): ModelQueryBuilder<T, ComposeSelect<S, {
6803
7217
  [P in Alias]: ValueType;
6804
- }>, R>;
7218
+ }>, R, D>;
6805
7219
  /**
6806
7220
  * @description Selects the keys of a JSON object at the specified path.
6807
7221
  * @param column - The column containing JSON object data. Accepts model column names (with IDE autocompletion)
@@ -6845,7 +7259,7 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
6845
7259
  */
6846
7260
  selectJsonKeys<K extends ModelKey<T> | (string & {}), ValueType = string[], Alias extends string = string>(column: K, path: K extends ModelKey<T> ? TypedJsonPathInput<ResolveColumnType<T, K & string>> : JsonPathInput, alias: Alias): ModelQueryBuilder<T, ComposeSelect<S, {
6847
7261
  [P in Alias]: ValueType;
6848
- }>, R>;
7262
+ }>, R, D>;
6849
7263
  /**
6850
7264
  * @description Adds a raw JSON select expression using database-specific SQL syntax.
6851
7265
  * @param raw - The raw SQL expression (database-specific syntax). Bypasses path standardization —
@@ -6885,7 +7299,7 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
6885
7299
  */
6886
7300
  selectJsonRaw<ValueType = any, Alias extends string = string>(raw: string, alias: Alias): ModelQueryBuilder<T, ComposeSelect<S, {
6887
7301
  [K in Alias]: ValueType;
6888
- }>, R>;
7302
+ }>, R, D>;
6889
7303
  /**
6890
7304
  * @description Fills the relations in the model in the serialized response. Relation must be defined with `definerelations` and passed in the `createSchema` function inside the SqlDataSource.
6891
7305
  * @warning Many to many relations have special behavior, since they require a join, a join clause will always be added to the query.
@@ -6912,22 +7326,22 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
6912
7326
  */
6913
7327
  load<RelationKey extends ModelRelation<T>>(relation: RelationKey): ModelQueryBuilder<T, S, R & {
6914
7328
  [K in RelationKey]: Awaited<ReturnType<ModelQueryBuilder<RelatedInstance<T, K>, ModelWithoutRelations<RelatedInstance<T, K>>, {}>[RelationRetrieveMethod<T[K]>]>>;
6915
- }>;
7329
+ }, D>;
6916
7330
  load<RelationKey extends ModelRelation<T>, IS extends Record<string, any> = ModelWithoutRelations<RelatedInstance<T, RelationKey>>, IR extends Record<string, any> = {}>(relation: RelationKey, queryBuilder: (queryBuilder: RelationQueryBuilderType<RelatedInstance<T, RelationKey>, ModelWithoutRelations<RelatedInstance<T, RelationKey>>, {}>) => RelationQueryBuilderType<RelatedInstance<T, RelationKey>, IS, IR>): ModelQueryBuilder<T, S, R & {
6917
7331
  [K in RelationKey]: Awaited<ReturnType<ModelQueryBuilder<RelatedInstance<T, K>, IS, IR>[RelationRetrieveMethod<T[K]>]>>;
6918
- }>;
7332
+ }, D>;
6919
7333
  load<RelationKey extends ModelRelation<T>>(relation: RelationKey, queryBuilder: (queryBuilder: RelationQueryBuilderType<RelatedInstance<T, RelationKey>, ModelWithoutRelations<RelatedInstance<T, RelationKey>>, {}>) => void): ModelQueryBuilder<T, S, R & {
6920
7334
  [K in RelationKey]: Awaited<ReturnType<ModelQueryBuilder<RelatedInstance<T, K>, ModelWithoutRelations<RelatedInstance<T, K>>, {}>[RelationRetrieveMethod<T[K]>]>>;
6921
- }>;
7335
+ }, D>;
6922
7336
  load<RelationKey extends ModelRelation<T>>(relation: RelationKey, options: LoadOptions): ModelQueryBuilder<T, S, R & {
6923
7337
  [K in RelationKey]: Awaited<ReturnType<ModelQueryBuilder<RelatedInstance<T, K>, ModelWithoutRelations<RelatedInstance<T, K>>, {}>[RelationRetrieveMethod<T[K]>]>>;
6924
- }>;
7338
+ }, D>;
6925
7339
  load<RelationKey extends ModelRelation<T>, IS extends Record<string, any> = ModelWithoutRelations<RelatedInstance<T, RelationKey>>, IR extends Record<string, any> = {}>(relation: RelationKey, queryBuilder: (queryBuilder: RelationQueryBuilderType<RelatedInstance<T, RelationKey>, ModelWithoutRelations<RelatedInstance<T, RelationKey>>, {}>) => RelationQueryBuilderType<RelatedInstance<T, RelationKey>, IS, IR>, options: LoadOptions): ModelQueryBuilder<T, S, R & {
6926
7340
  [K in RelationKey]: Awaited<ReturnType<ModelQueryBuilder<RelatedInstance<T, K>, IS, IR>[RelationRetrieveMethod<T[K]>]>>;
6927
- }>;
7341
+ }, D>;
6928
7342
  load<RelationKey extends ModelRelation<T>>(relation: RelationKey, queryBuilder: (queryBuilder: RelationQueryBuilderType<RelatedInstance<T, RelationKey>, ModelWithoutRelations<RelatedInstance<T, RelationKey>>, {}>) => void, options: LoadOptions): ModelQueryBuilder<T, S, R & {
6929
7343
  [K in RelationKey]: Awaited<ReturnType<ModelQueryBuilder<RelatedInstance<T, K>, ModelWithoutRelations<RelatedInstance<T, K>>, {}>[RelationRetrieveMethod<T[K]>]>>;
6930
- }>;
7344
+ }, D>;
6931
7345
  /**
6932
7346
  * @description Clears the relations from the query builder
6933
7347
  */
@@ -6937,37 +7351,37 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
6937
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
6938
7352
  */
6939
7353
  havingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, cb?: (queryBuilder: ModelQueryBuilder<RelatedInstance<T, RelationKey>>) => void): this;
6940
- 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;
6941
7355
  /**
6942
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
6943
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
6944
7358
  */
6945
7359
  andHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, cb?: (queryBuilder: ModelQueryBuilder<RelatedInstance<T, RelationKey>>) => void): this;
6946
- 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;
6947
7361
  /**
6948
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,
6949
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
6950
7364
  */
6951
7365
  orHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, cb?: (queryBuilder: ModelQueryBuilder<RelatedInstance<T, RelationKey>>) => void): this;
6952
- 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;
6953
7367
  /**
6954
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
6955
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
6956
7370
  */
6957
7371
  notHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, cb?: (queryBuilder: ModelQueryBuilder<RelatedInstance<T, RelationKey>>) => void): this;
6958
- 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;
6959
7373
  /**
6960
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
6961
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
6962
7376
  */
6963
7377
  andNotHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, cb?: (queryBuilder: ModelQueryBuilder<RelatedInstance<T, RelationKey>>) => void): this;
6964
- 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;
6965
7379
  /**
6966
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
6967
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
6968
7382
  */
6969
7383
  orNotHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, cb?: (queryBuilder: ModelQueryBuilder<RelatedInstance<T, RelationKey>>) => void): this;
6970
- 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;
6971
7385
  /**
6972
7386
  * @description Returns a copy of the query builder instance.
6973
7387
  */
@@ -7017,9 +7431,9 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
7017
7431
  protected loadRelationViaBatch(relationQueryBuilder: ModelQueryBuilder<any>, models: T[]): Promise<void>;
7018
7432
  protected mapRelatedModelsToModels<R extends SelectedModel<T, ModelWithoutRelations<T>, Record<string, any>>>(relation: Relation, modelsToFillWithRelations: T[], relatedModels: R[]): void;
7019
7433
  protected getRelatedModelsForRelation(relationQueryBuilder: ModelQueryBuilder<any>, relation: Relation, models: T[]): Promise<SelectedModel<T, ModelWithoutRelations<T>, R>[]>;
7020
- protected getRelatedModelsQueryForRelation(relationQueryBuilder: ModelQueryBuilder<any>, relation: Relation, models: T[]): ModelQueryBuilder<any, any, any>;
7434
+ protected getRelatedModelsQueryForRelation(relationQueryBuilder: ModelQueryBuilder<any>, relation: Relation, models: T[]): ModelQueryBuilder<any, any, any, D>;
7021
7435
  protected getFilterValuesFromModelsForRelation(relation: Relation, models: T[]): any[];
7022
- 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;
7023
7437
  }
7024
7438
 
7025
7439
  /**
@@ -8703,7 +9117,7 @@ declare abstract class BaseSeeder {
8703
9117
  abstract run(): Promise<void>;
8704
9118
  }
8705
9119
 
8706
- 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" | "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}`;
8707
9121
 
8708
9122
  declare class HysteriaError extends Error {
8709
9123
  code: HysteriaErrorCode;
@@ -8866,4 +9280,4 @@ type BetterAuthAdapterConfig = Partial<Pick<AdapterFactoryConfig, "usePlural" |
8866
9280
  */
8867
9281
  declare function betterAuthAdapter(sql: SqlDataSource, config?: BetterAuthAdapterConfig): (options: BetterAuthOptions) => DBAdapter;
8868
9282
 
8869
- export { type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AllowedDrivers, type AnyModelConstructor, type AnySqlDataSourceInput, type AtomicOptions, type BaseModelMethodOptions, BaseSeeder, type BeginTransactionOptions, type BetterAuthAdapterConfig, type BuildSelectType, type BuildSingleSelectType, type BuiltinDriverName, type CacheAdapter, type CacheKeys, ClientMigrator, type ColCharOptions, type ColComputedOptions, type ColJsonbOptions, type ColMediumIntOptions, type ColSmallIntOptions, type ColTinyIntOptions, type ColVarbinaryOptions, Collection, type CollectionDefinition, type ColumnDef, type CommonDataSourceInput, type ComposeBuildSelect, type ComposeSelect, type ComputedColumnDef, type ConnectionPolicies, type CreateSchemaResult, type CustomLogger, type DataSourceInput, type DataSourceType, type DateAutoHook, type DefinedCollection, type DefinedModel, type DefinedView, type DriverAdapter, type DriverAdapterFactory, type DriverAdapterFactoryContext, type EndTransactionOptions, type ExcludeMethods, type ExecuteOptions, type ExtractColumnName, type ExtractSourceColumn, type FindReturnType, type GetColumnType, type GetConnectionReturnType, HysteriaError, type HysteriaErrorCode, InMemoryAdapter, type InferPK, type IntrospectedColumn, type IntrospectedForeignKey, type IntrospectedSchema, type IntrospectedTable, type JsEnvironmentValue, type JsonPathInput, type JsonPaths, type LoadOptions, type LoggerConfig, Migration, type MigrationConfig, type MigrationConfigBase, type MigrationLockConfig, type ModelColumns, type ModelDataProperties, type ModelInstanceType, type ModelKey, ModelQueryBuilder, type ModelQueryResult, type ModelRelation, type ModelSelectTuple, type ModelSelectableInput, type ModelStream, type ModelWithoutRelations, type ModelsProxy, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MutationReturningResult, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NullableColumn, type NumberModelKey, ObserverChain, ObserverChainWrapper, type Operation, type PgPoolClientInstance, type PingResult, type PlatformAdapter, type PlatformFs, type PlatformPath, PlatformUnsupportedError, type PostgresSqlDataSourceInput, type PrimaryColumnDef, type PropNamespace, type PropertyDef, QueryBuilder, type QueryContext, type QueryContextWithDuration, type QueryObserver, type RawModelKey, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationDef, type RelationDefinitions, type RelationHelpers, type RelationLoadStrategy, type RelationQueryBuilderType, type ReplicationType, type ResolveColumnType, type ResolveJsonPathType, type ResolvedJsEnvironment, type ReturningColumns, type ReturningKey, type ReturningParam, type ReturningResult, type ReturningResultMany, type ReturningSupported, Schema, SchemaBuilder, type SchemaLookup, type SchemaRelDef, type SeederConfig, type SelectBrand, type SelectableColumn, type SelectedModel, type SlaveAlgorithm, type SlaveContext, type SqlCloneOptions, SqlDataSource, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDriverSpecificOptions, SqlFuncNode, type SqlFuncRenderer, type SqlPoolType, type Sqlite3ConnectionOptions, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type StripTablePrefix, type SubQueryable, type TableFormat, Transaction, type TransactionExecutionOptions, type TypedDefault, type TypedJsonPathInput, type TypedPrepare, type TypedSerialize, type UseCacheReturnType, type UseConnectionInput, type ValidationContext, ValidationError, type ValidationResult, type Validator, type ViewDefinition, WriteOperation, type WriteReturnType, atomic, betterAuthAdapter, col, createSchema, defineCollection, defineMigrator, defineModel, defineModelFactory, defineRelations, defineView, deriveOperationFromQuery, email, enumValidator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, type getPoolReturnType, loadPlatform, HysteriaLogger as logger, max, maxLength, min, minLength, pattern, prop, RedisDataSource as redis, registerDriverAdapter, registerSqlFuncRenderer, required, sqlFunc, url };
9283
+ export { type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AllowedDrivers, type AnyModelConstructor, type AnySqlDataSourceInput, type AtomicOptions, type BaseModelMethodOptions, BaseSeeder, type BeginTransactionOptions, type BetterAuthAdapterConfig, type BuildSelectType, type BuildSingleSelectType, type BuiltinDriverName, type CacheAdapter, type CacheKeys, ClientMigrator, type ColCharOptions, type ColComputedOptions, type ColJsonbOptions, type ColMediumIntOptions, type ColSmallIntOptions, type ColTinyIntOptions, type ColVarbinaryOptions, Collection, type CollectionDefinition, type ColumnDef, type CommonDataSourceInput, type ComposeBuildSelect, type ComposeSelect, type ComputedColumnDef, type ConnectionPolicies, type CreateSchemaResult, type CustomLogger, type DataSourceInput, type DataSourceType, type DateAutoHook, type DefinedCollection, type DefinedModel, type DefinedView, type DriverAdapter, type DriverAdapterFactory, type DriverAdapterFactoryContext, type EndTransactionOptions, type ExcludeMethods, type ExecuteOptions, type ExtractColumnName, type ExtractSourceColumn, type FindReturnType, type GetColumnType, type GetConnectionReturnType, HysteriaError, type HysteriaErrorCode, InMemoryAdapter, type InferPK, type IntrospectedColumn, type IntrospectedForeignKey, type IntrospectedSchema, type IntrospectedTable, type JsEnvironmentValue, type JsonPathInput, type JsonPaths, type LoadOptions, type LoggerConfig, Migration, type MigrationConfig, type MigrationConfigBase, type MigrationLockConfig, type ModelColumns, type ModelDataProperties, type ModelInstanceType, type ModelKey, ModelQueryBuilder, type ModelQueryResult, type ModelRelation, type ModelSelectTuple, type ModelSelectableInput, type ModelStream, type ModelWithoutRelations, type ModelsProxy, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlComment, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MutationReturningResult, type MySqlComment, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NullableColumn, type NumberModelKey, ObserverChain, ObserverChainWrapper, type Operation, type PgComment, type PgPoolClientInstance, type PingResult, type PlatformAdapter, type PlatformFs, type PlatformPath, PlatformUnsupportedError, type PostgresSqlDataSourceInput, type PrimaryColumnDef, type PropNamespace, type PropertyDef, QueryBuilder, type QueryContext, type QueryContextWithDuration, type QueryObserver, type RawModelKey, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationDef, type RelationDefinitions, type RelationHelpers, type RelationLoadStrategy, type RelationQueryBuilderType, type ReplicationType, type ResolveColumnType, type ResolveJsonPathType, type ResolvedJsEnvironment, type ReturningColumns, type ReturningKey, type ReturningParam, type ReturningResult, type ReturningResultMany, type ReturningSupported, Schema, SchemaBuilder, type SchemaLookup, type SchemaRelDef, type SeederConfig, type SelectBrand, type SelectableColumn, type SelectedModel, type SlaveAlgorithm, type SlaveContext, type SqlCloneOptions, type SqlComment, SqlDataSource, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDriverSpecificOptions, SqlFuncNode, type SqlFuncRenderer, type SqlHint, type SqlPoolType, type Sqlite3ConnectionOptions, type SqliteComment, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type StripTablePrefix, type SubQueryable, type TableFormat, Transaction, type TransactionExecutionOptions, type TypedDefault, type TypedJsonPathInput, type TypedPrepare, type TypedSerialize, type UseCacheReturnType, type UseConnectionInput, type ValidationContext, ValidationError, type ValidationResult, type Validator, type ViewDefinition, WriteOperation, type WriteReturnType, atomic, betterAuthAdapter, col, createSchema, defineCollection, defineMigrator, defineModel, defineModelFactory, defineRelations, defineView, deriveOperationFromQuery, email, enumValidator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, type getPoolReturnType, loadPlatform, HysteriaLogger as logger, max, maxLength, min, minLength, pattern, prop, RedisDataSource as redis, registerDriverAdapter, registerSqlFuncRenderer, required, sqlFunc, url };