hysteria-orm 10.5.9 → 10.6.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.cts CHANGED
@@ -3780,84 +3780,90 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
3780
3780
  /**
3781
3781
  * @description Adds a WHERE condition to the query.
3782
3782
  */
3783
- where(column: ModelKey<T>, operator: BinaryOperatorType, value: BaseValues): this;
3784
- where<S extends string>(column: SelectableColumn$1<S>, operator: BinaryOperatorType, value: BaseValues): this;
3785
3783
  where(cb: (queryBuilder: WhereOnlyQueryBuilder<T>) => void): this;
3786
- where(column: ModelKey<T> | SelectableColumn$1<string>, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3787
- where(column: ModelKey<T> | SelectableColumn$1<string>, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3788
- where(column: ModelKey<T> | SelectableColumn$1<string>, value: BaseValues): this;
3784
+ where(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3785
+ where(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3786
+ where<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType, value: WhereColumnValue<T, K>): this;
3787
+ where<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
3788
+ where(column: `${string}.${string}`, operator: BinaryOperatorType, value: BaseValues): this;
3789
+ where(column: `${string}.${string}`, value: BaseValues): this;
3789
3790
  /**
3790
3791
  * @description Adds an AND WHERE condition to the query.
3791
3792
  */
3792
- andWhere(column: ModelKey<T>, operator: BinaryOperatorType, value: BaseValues): this;
3793
- andWhere(column: SelectableColumn$1<string>, operator: BinaryOperatorType, value: BaseValues): this;
3794
- andWhere(column: ModelKey<T> | SelectableColumn$1<string>, value: BaseValues): this;
3795
3793
  andWhere(cb: (queryBuilder: WhereOnlyQueryBuilder<T>) => void): this;
3796
- andWhere(column: ModelKey<T> | SelectableColumn$1<string>, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3797
- andWhere(column: ModelKey<T> | SelectableColumn$1<string>, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3794
+ andWhere(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3795
+ andWhere(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3796
+ andWhere<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType, value: WhereColumnValue<T, K>): this;
3797
+ andWhere<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
3798
+ andWhere(column: `${string}.${string}`, operator: BinaryOperatorType, value: BaseValues): this;
3799
+ andWhere(column: `${string}.${string}`, value: BaseValues): this;
3798
3800
  /**
3799
3801
  * @description Adds an OR WHERE condition to the query.
3800
3802
  */
3801
- orWhere(column: ModelKey<T>, operator: BinaryOperatorType, value: BaseValues): this;
3802
- orWhere<S extends string>(column: SelectableColumn$1<S>, operator: BinaryOperatorType, value: BaseValues): this;
3803
- orWhere<S extends string>(column: ModelKey<T> | SelectableColumn$1<S>, value: BaseValues): this;
3804
3803
  orWhere(cb: (queryBuilder: WhereOnlyQueryBuilder<T>) => void): this;
3805
- orWhere(column: ModelKey<T> | SelectableColumn$1<string>, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3806
- orWhere(column: ModelKey<T> | SelectableColumn$1<string>, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3804
+ orWhere(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3805
+ orWhere(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3806
+ orWhere<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType, value: WhereColumnValue<T, K>): this;
3807
+ orWhere<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
3808
+ orWhere(column: `${string}.${string}`, operator: BinaryOperatorType, value: BaseValues): this;
3809
+ orWhere(column: `${string}.${string}`, value: BaseValues): this;
3807
3810
  /**
3808
3811
  * @description Adds a negated WHERE condition to the query.
3809
3812
  */
3810
- whereNot(column: ModelKey<T>, operator: BinaryOperatorType, value: BaseValues): this;
3811
- whereNot<S extends string>(column: SelectableColumn$1<S>, operator: BinaryOperatorType, value: BaseValues): this;
3812
- whereNot(column: ModelKey<T> | SelectableColumn$1<string>, value: BaseValues): this;
3813
- whereNot(column: ModelKey<T> | SelectableColumn$1<string>, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3814
- whereNot(column: ModelKey<T> | SelectableColumn$1<string>, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3813
+ whereNot(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3814
+ whereNot(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3815
+ whereNot<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType, value: WhereColumnValue<T, K>): this;
3816
+ whereNot<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
3817
+ whereNot(column: `${string}.${string}`, operator: BinaryOperatorType, value: BaseValues): this;
3818
+ whereNot(column: `${string}.${string}`, value: BaseValues): this;
3815
3819
  /**
3816
3820
  * @description Adds a negated AND WHERE condition to the query.
3817
3821
  */
3818
- andWhereNot(column: ModelKey<T>, operator: BinaryOperatorType, value: BaseValues): this;
3819
- andWhereNot<S extends string>(column: SelectableColumn$1<S>, operator: BinaryOperatorType, value: BaseValues): this;
3820
- andWhereNot(column: ModelKey<T> | SelectableColumn$1<string>, value: BaseValues): this;
3821
- andWhereNot(column: ModelKey<T> | SelectableColumn$1<string>, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3822
- andWhereNot(column: ModelKey<T> | SelectableColumn$1<string>, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3822
+ andWhereNot(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3823
+ andWhereNot(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3824
+ andWhereNot<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType, value: WhereColumnValue<T, K>): this;
3825
+ andWhereNot<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
3826
+ andWhereNot(column: `${string}.${string}`, operator: BinaryOperatorType, value: BaseValues): this;
3827
+ andWhereNot(column: `${string}.${string}`, value: BaseValues): this;
3823
3828
  /**
3824
3829
  * @description Adds a negated OR WHERE condition to the query.
3825
3830
  */
3826
- orWhereNot(column: ModelKey<T>, operator: BinaryOperatorType, value: BaseValues): this;
3827
- orWhereNot<S extends string>(column: SelectableColumn$1<S>, operator: BinaryOperatorType, value: BaseValues): this;
3828
- orWhereNot(column: ModelKey<T> | SelectableColumn$1<string>, value: BaseValues): this;
3829
- orWhereNot(column: ModelKey<T> | SelectableColumn$1<string>, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3830
- orWhereNot(column: ModelKey<T> | SelectableColumn$1<string>, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3831
+ orWhereNot(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3832
+ orWhereNot(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3833
+ orWhereNot<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType, value: WhereColumnValue<T, K>): this;
3834
+ orWhereNot<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
3835
+ orWhereNot(column: `${string}.${string}`, operator: BinaryOperatorType, value: BaseValues): this;
3836
+ orWhereNot(column: `${string}.${string}`, value: BaseValues): this;
3831
3837
  /**
3832
3838
  * @description Adds a WHERE BETWEEN condition to the query.
3833
3839
  */
3834
- whereBetween(column: ModelKey<T>, min: BaseValues, max: BaseValues): this;
3835
- whereBetween<S extends string>(column: SelectableColumn$1<S>, min: BaseValues, max: BaseValues): this;
3840
+ whereBetween<K extends ModelKey<T>>(column: K, min: T[K], max: T[K]): this;
3841
+ whereBetween(column: `${string}.${string}`, min: BaseValues, max: BaseValues): this;
3836
3842
  /**
3837
3843
  * @description Adds an AND WHERE BETWEEN condition to the query.
3838
3844
  */
3839
- andWhereBetween(column: ModelKey<T>, min: BaseValues, max: BaseValues): this;
3840
- andWhereBetween<S extends string>(column: SelectableColumn$1<S>, min: BaseValues, max: BaseValues): this;
3845
+ andWhereBetween<K extends ModelKey<T>>(column: K, min: T[K], max: T[K]): this;
3846
+ andWhereBetween(column: `${string}.${string}`, min: BaseValues, max: BaseValues): this;
3841
3847
  /**
3842
3848
  * @description Adds an OR WHERE BETWEEN condition to the query.
3843
3849
  */
3844
- orWhereBetween(column: ModelKey<T>, min: BaseValues, max: BaseValues): this;
3845
- orWhereBetween<S extends string>(column: SelectableColumn$1<S>, min: BaseValues, max: BaseValues): this;
3850
+ orWhereBetween<K extends ModelKey<T>>(column: K, min: T[K], max: T[K]): this;
3851
+ orWhereBetween(column: `${string}.${string}`, min: BaseValues, max: BaseValues): this;
3846
3852
  /**
3847
3853
  * @description Adds a WHERE NOT BETWEEN condition to the query.
3848
3854
  */
3849
- whereNotBetween(column: ModelKey<T>, min: BaseValues, max: BaseValues): this;
3850
- whereNotBetween<S extends string>(column: SelectableColumn$1<S>, min: BaseValues, max: BaseValues): this;
3855
+ whereNotBetween<K extends ModelKey<T>>(column: K, min: T[K], max: T[K]): this;
3856
+ whereNotBetween(column: `${string}.${string}`, min: BaseValues, max: BaseValues): this;
3851
3857
  /**
3852
3858
  * @description Adds an AND WHERE NOT BETWEEN condition to the query.
3853
3859
  */
3854
- andWhereNotBetween(column: ModelKey<T>, min: BaseValues, max: BaseValues): this;
3855
- andWhereNotBetween<S extends string>(column: SelectableColumn$1<S>, min: BaseValues, max: BaseValues): this;
3860
+ andWhereNotBetween<K extends ModelKey<T>>(column: K, min: T[K], max: T[K]): this;
3861
+ andWhereNotBetween(column: `${string}.${string}`, min: BaseValues, max: BaseValues): this;
3856
3862
  /**
3857
3863
  * @description Adds an OR WHERE NOT BETWEEN condition to the query.
3858
3864
  */
3859
- orWhereNotBetween(column: ModelKey<T>, min: BaseValues, max: BaseValues): this;
3860
- orWhereNotBetween<S extends string>(column: SelectableColumn$1<S>, min: BaseValues, max: BaseValues): this;
3865
+ orWhereNotBetween<K extends ModelKey<T>>(column: K, min: T[K], max: T[K]): this;
3866
+ orWhereNotBetween(column: `${string}.${string}`, min: BaseValues, max: BaseValues): this;
3861
3867
  /**
3862
3868
  * @description Adds a WHERE LIKE condition to the query.
3863
3869
  */
@@ -3922,38 +3928,44 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
3922
3928
  * @description Adds a WHERE IN condition to the query.
3923
3929
  * @warning If the array is empty, it will add an impossible condition.
3924
3930
  */
3925
- whereIn(column: ModelKey<T>, values: BaseValues[]): this;
3926
- whereIn<S extends string>(column: SelectableColumn$1<S>, values: BaseValues[]): this;
3931
+ whereIn(column: string, values: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3932
+ whereIn<K extends ModelKey<T>>(column: K, values: T[K][]): this;
3933
+ whereIn(column: `${string}.${string}`, values: BaseValues[]): this;
3927
3934
  /**
3928
3935
  * @description Adds an AND WHERE IN condition to the query.
3929
3936
  * @warning If the array is empty, it will add an impossible condition.
3930
3937
  */
3931
- andWhereIn(column: ModelKey<T>, values: BaseValues[]): this;
3932
- andWhereIn<S extends string>(column: SelectableColumn$1<S>, values: BaseValues[]): this;
3938
+ andWhereIn(column: string, values: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3939
+ andWhereIn<K extends ModelKey<T>>(column: K, values: T[K][]): this;
3940
+ andWhereIn(column: `${string}.${string}`, values: BaseValues[]): this;
3933
3941
  /**
3934
3942
  * @description Adds an OR WHERE IN condition to the query.
3935
3943
  * @warning If the array is empty, it will add an impossible condition.
3936
3944
  */
3937
- orWhereIn(column: ModelKey<T>, values: BaseValues[]): this;
3938
- orWhereIn<S extends string>(column: SelectableColumn$1<S>, values: BaseValues[]): this;
3945
+ orWhereIn(column: string, values: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3946
+ orWhereIn<K extends ModelKey<T>>(column: K, values: T[K][]): this;
3947
+ orWhereIn(column: `${string}.${string}`, values: BaseValues[]): this;
3939
3948
  /**
3940
3949
  * @description Adds a WHERE NOT IN condition to the query.
3941
3950
  * @warning If the array is empty, it will add an obvious condition to make it true.
3942
3951
  */
3943
- whereNotIn(column: ModelKey<T>, values: BaseValues[]): this;
3944
- whereNotIn<S extends string>(column: SelectableColumn$1<S>, values: BaseValues[]): this;
3952
+ whereNotIn(column: string, values: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3953
+ whereNotIn<K extends ModelKey<T>>(column: K, values: T[K][]): this;
3954
+ whereNotIn(column: `${string}.${string}`, values: BaseValues[]): this;
3945
3955
  /**
3946
3956
  * @description Adds an OR WHERE NOT IN condition to the query.
3947
3957
  * @warning If the array is empty, it will add an obvious condition to make it true.
3948
3958
  */
3949
- andWhereNotIn(column: ModelKey<T>, values: BaseValues[]): this;
3950
- andWhereNotIn<S extends string>(column: SelectableColumn$1<S>, values: BaseValues[]): this;
3959
+ andWhereNotIn(column: string, values: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3960
+ andWhereNotIn<K extends ModelKey<T>>(column: K, values: T[K][]): this;
3961
+ andWhereNotIn(column: `${string}.${string}`, values: BaseValues[]): this;
3951
3962
  /**
3952
3963
  * @description Adds an OR WHERE NOT IN condition to the query.
3953
3964
  * @warning If the array is empty, it will add an obvious condition to make it true.
3954
3965
  */
3955
- orWhereNotIn(column: ModelKey<T>, values: BaseValues[]): this;
3956
- orWhereNotIn<S extends string>(column: SelectableColumn$1<S>, values: BaseValues[]): this;
3966
+ orWhereNotIn(column: string, values: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3967
+ orWhereNotIn<K extends ModelKey<T>>(column: K, values: T[K][]): this;
3968
+ orWhereNotIn(column: `${string}.${string}`, values: BaseValues[]): this;
3957
3969
  /**
3958
3970
  * @description Adds a WHERE NULL condition to the query.
3959
3971
  */
@@ -4065,18 +4077,25 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
4065
4077
  /**
4066
4078
  * @description Adds a HAVING condition to the query.
4067
4079
  */
4068
- having<S extends string>(column: SelectableColumn$1<S>, value: any): this;
4069
- having(column: ModelKey<T>, operator: BinaryOperatorType, value: any): this;
4080
+ having<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
4081
+ having<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType, value: WhereColumnValue<T, K>): this;
4082
+ having(column: `${string}.${string}`, value: any): this;
4083
+ having(column: `${string}.${string}`, operator: BinaryOperatorType, value: any): this;
4070
4084
  /**
4071
4085
  * @description Adds an AND HAVING condition to the query.
4072
4086
  */
4073
- andHaving<S extends string>(column: SelectableColumn$1<S>, value: any): this;
4087
+ andHaving<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
4088
+ andHaving<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType, value: WhereColumnValue<T, K>): this;
4089
+ andHaving(column: `${string}.${string}`, value: any): this;
4090
+ andHaving(column: `${string}.${string}`, operator: BinaryOperatorType, value: any): this;
4074
4091
  andHaving(column: ModelKey<T>, operator: BinaryOperatorType, value: any): this;
4075
4092
  /**
4076
4093
  * @description Adds an OR HAVING condition to the query.
4077
4094
  */
4078
- orHaving<S extends string>(column: SelectableColumn$1<S>, value: any): this;
4079
- orHaving(column: ModelKey<T>, operator: BinaryOperatorType, value: any): this;
4095
+ orHaving<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
4096
+ orHaving<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType, value: WhereColumnValue<T, K>): this;
4097
+ orHaving(column: `${string}.${string}`, value: any): this;
4098
+ orHaving(column: `${string}.${string}`, operator: BinaryOperatorType, value: any): this;
4080
4099
  /**
4081
4100
  * @description Adds a raw HAVING condition to the query.
4082
4101
  */
@@ -4534,19 +4553,19 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
4534
4553
  update(data: Partial<ModelWithoutRelations<T>>, options?: UpdateOptions): WriteOperation<number>;
4535
4554
  softDelete(options?: SoftDeleteOptions<T>): WriteOperation<number>;
4536
4555
  delete(options?: DeleteOptions): WriteOperation<number>;
4537
- getCount(column?: string, options?: {
4556
+ getCount(column?: (ModelKey<T> & string) | "*" | (string & {}), options?: {
4538
4557
  ignoreHooks: boolean;
4539
4558
  }): Promise<number>;
4540
- getMax(column: string, options?: {
4559
+ getMax(column: (ModelKey<T> & string) | (string & {}), options?: {
4541
4560
  ignoreHooks: boolean;
4542
4561
  }): Promise<number>;
4543
- getMin(column: string, options?: {
4562
+ getMin(column: (ModelKey<T> & string) | (string & {}), options?: {
4544
4563
  ignoreHooks: boolean;
4545
4564
  }): Promise<number>;
4546
- getAvg(column: string, options?: {
4565
+ getAvg(column: (ModelKey<T> & string) | (string & {}), options?: {
4547
4566
  ignoreHooks: boolean;
4548
4567
  }): Promise<number>;
4549
- getSum(column: string, options?: {
4568
+ getSum(column: (ModelKey<T> & string) | (string & {}), options?: {
4550
4569
  ignoreHooks: boolean;
4551
4570
  }): Promise<number>;
4552
4571
  paginate(page: number, perPage: number, options?: {
@@ -6044,6 +6063,11 @@ type WhereType<T> = BaseWhereType<T> & {
6044
6063
  type ModelKey<T extends Model> = {
6045
6064
  [K in keyof T]: T[K] extends NullableAndUndefinable<Model> | NullableAndUndefinable<Model[]> ? never : K extends "*" ? never : T[K] extends (...args: any[]) => any ? never : K;
6046
6065
  }[keyof T];
6066
+ /**
6067
+ * Extracts the value type for a model column key, adding `null` for SQL compatibility.
6068
+ * Used in type-safe where/having clauses to infer value types from column keys.
6069
+ */
6070
+ type WhereColumnValue<T extends Model, K extends ModelKey<T>> = T[K] | null;
6047
6071
  type ModelRelation<T extends Model> = OnlyRelations<T>;
6048
6072
  type OrderByChoices = "asc" | "desc";
6049
6073
  type OrderByType<T extends Model> = {
package/lib/index.d.ts CHANGED
@@ -3780,84 +3780,90 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
3780
3780
  /**
3781
3781
  * @description Adds a WHERE condition to the query.
3782
3782
  */
3783
- where(column: ModelKey<T>, operator: BinaryOperatorType, value: BaseValues): this;
3784
- where<S extends string>(column: SelectableColumn$1<S>, operator: BinaryOperatorType, value: BaseValues): this;
3785
3783
  where(cb: (queryBuilder: WhereOnlyQueryBuilder<T>) => void): this;
3786
- where(column: ModelKey<T> | SelectableColumn$1<string>, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3787
- where(column: ModelKey<T> | SelectableColumn$1<string>, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3788
- where(column: ModelKey<T> | SelectableColumn$1<string>, value: BaseValues): this;
3784
+ where(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3785
+ where(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3786
+ where<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType, value: WhereColumnValue<T, K>): this;
3787
+ where<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
3788
+ where(column: `${string}.${string}`, operator: BinaryOperatorType, value: BaseValues): this;
3789
+ where(column: `${string}.${string}`, value: BaseValues): this;
3789
3790
  /**
3790
3791
  * @description Adds an AND WHERE condition to the query.
3791
3792
  */
3792
- andWhere(column: ModelKey<T>, operator: BinaryOperatorType, value: BaseValues): this;
3793
- andWhere(column: SelectableColumn$1<string>, operator: BinaryOperatorType, value: BaseValues): this;
3794
- andWhere(column: ModelKey<T> | SelectableColumn$1<string>, value: BaseValues): this;
3795
3793
  andWhere(cb: (queryBuilder: WhereOnlyQueryBuilder<T>) => void): this;
3796
- andWhere(column: ModelKey<T> | SelectableColumn$1<string>, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3797
- andWhere(column: ModelKey<T> | SelectableColumn$1<string>, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3794
+ andWhere(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3795
+ andWhere(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3796
+ andWhere<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType, value: WhereColumnValue<T, K>): this;
3797
+ andWhere<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
3798
+ andWhere(column: `${string}.${string}`, operator: BinaryOperatorType, value: BaseValues): this;
3799
+ andWhere(column: `${string}.${string}`, value: BaseValues): this;
3798
3800
  /**
3799
3801
  * @description Adds an OR WHERE condition to the query.
3800
3802
  */
3801
- orWhere(column: ModelKey<T>, operator: BinaryOperatorType, value: BaseValues): this;
3802
- orWhere<S extends string>(column: SelectableColumn$1<S>, operator: BinaryOperatorType, value: BaseValues): this;
3803
- orWhere<S extends string>(column: ModelKey<T> | SelectableColumn$1<S>, value: BaseValues): this;
3804
3803
  orWhere(cb: (queryBuilder: WhereOnlyQueryBuilder<T>) => void): this;
3805
- orWhere(column: ModelKey<T> | SelectableColumn$1<string>, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3806
- orWhere(column: ModelKey<T> | SelectableColumn$1<string>, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3804
+ orWhere(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3805
+ orWhere(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3806
+ orWhere<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType, value: WhereColumnValue<T, K>): this;
3807
+ orWhere<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
3808
+ orWhere(column: `${string}.${string}`, operator: BinaryOperatorType, value: BaseValues): this;
3809
+ orWhere(column: `${string}.${string}`, value: BaseValues): this;
3807
3810
  /**
3808
3811
  * @description Adds a negated WHERE condition to the query.
3809
3812
  */
3810
- whereNot(column: ModelKey<T>, operator: BinaryOperatorType, value: BaseValues): this;
3811
- whereNot<S extends string>(column: SelectableColumn$1<S>, operator: BinaryOperatorType, value: BaseValues): this;
3812
- whereNot(column: ModelKey<T> | SelectableColumn$1<string>, value: BaseValues): this;
3813
- whereNot(column: ModelKey<T> | SelectableColumn$1<string>, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3814
- whereNot(column: ModelKey<T> | SelectableColumn$1<string>, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3813
+ whereNot(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3814
+ whereNot(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3815
+ whereNot<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType, value: WhereColumnValue<T, K>): this;
3816
+ whereNot<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
3817
+ whereNot(column: `${string}.${string}`, operator: BinaryOperatorType, value: BaseValues): this;
3818
+ whereNot(column: `${string}.${string}`, value: BaseValues): this;
3815
3819
  /**
3816
3820
  * @description Adds a negated AND WHERE condition to the query.
3817
3821
  */
3818
- andWhereNot(column: ModelKey<T>, operator: BinaryOperatorType, value: BaseValues): this;
3819
- andWhereNot<S extends string>(column: SelectableColumn$1<S>, operator: BinaryOperatorType, value: BaseValues): this;
3820
- andWhereNot(column: ModelKey<T> | SelectableColumn$1<string>, value: BaseValues): this;
3821
- andWhereNot(column: ModelKey<T> | SelectableColumn$1<string>, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3822
- andWhereNot(column: ModelKey<T> | SelectableColumn$1<string>, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3822
+ andWhereNot(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3823
+ andWhereNot(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3824
+ andWhereNot<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType, value: WhereColumnValue<T, K>): this;
3825
+ andWhereNot<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
3826
+ andWhereNot(column: `${string}.${string}`, operator: BinaryOperatorType, value: BaseValues): this;
3827
+ andWhereNot(column: `${string}.${string}`, value: BaseValues): this;
3823
3828
  /**
3824
3829
  * @description Adds a negated OR WHERE condition to the query.
3825
3830
  */
3826
- orWhereNot(column: ModelKey<T>, operator: BinaryOperatorType, value: BaseValues): this;
3827
- orWhereNot<S extends string>(column: SelectableColumn$1<S>, operator: BinaryOperatorType, value: BaseValues): this;
3828
- orWhereNot(column: ModelKey<T> | SelectableColumn$1<string>, value: BaseValues): this;
3829
- orWhereNot(column: ModelKey<T> | SelectableColumn$1<string>, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3830
- orWhereNot(column: ModelKey<T> | SelectableColumn$1<string>, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3831
+ orWhereNot(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3832
+ orWhereNot(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3833
+ orWhereNot<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType, value: WhereColumnValue<T, K>): this;
3834
+ orWhereNot<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
3835
+ orWhereNot(column: `${string}.${string}`, operator: BinaryOperatorType, value: BaseValues): this;
3836
+ orWhereNot(column: `${string}.${string}`, value: BaseValues): this;
3831
3837
  /**
3832
3838
  * @description Adds a WHERE BETWEEN condition to the query.
3833
3839
  */
3834
- whereBetween(column: ModelKey<T>, min: BaseValues, max: BaseValues): this;
3835
- whereBetween<S extends string>(column: SelectableColumn$1<S>, min: BaseValues, max: BaseValues): this;
3840
+ whereBetween<K extends ModelKey<T>>(column: K, min: T[K], max: T[K]): this;
3841
+ whereBetween(column: `${string}.${string}`, min: BaseValues, max: BaseValues): this;
3836
3842
  /**
3837
3843
  * @description Adds an AND WHERE BETWEEN condition to the query.
3838
3844
  */
3839
- andWhereBetween(column: ModelKey<T>, min: BaseValues, max: BaseValues): this;
3840
- andWhereBetween<S extends string>(column: SelectableColumn$1<S>, min: BaseValues, max: BaseValues): this;
3845
+ andWhereBetween<K extends ModelKey<T>>(column: K, min: T[K], max: T[K]): this;
3846
+ andWhereBetween(column: `${string}.${string}`, min: BaseValues, max: BaseValues): this;
3841
3847
  /**
3842
3848
  * @description Adds an OR WHERE BETWEEN condition to the query.
3843
3849
  */
3844
- orWhereBetween(column: ModelKey<T>, min: BaseValues, max: BaseValues): this;
3845
- orWhereBetween<S extends string>(column: SelectableColumn$1<S>, min: BaseValues, max: BaseValues): this;
3850
+ orWhereBetween<K extends ModelKey<T>>(column: K, min: T[K], max: T[K]): this;
3851
+ orWhereBetween(column: `${string}.${string}`, min: BaseValues, max: BaseValues): this;
3846
3852
  /**
3847
3853
  * @description Adds a WHERE NOT BETWEEN condition to the query.
3848
3854
  */
3849
- whereNotBetween(column: ModelKey<T>, min: BaseValues, max: BaseValues): this;
3850
- whereNotBetween<S extends string>(column: SelectableColumn$1<S>, min: BaseValues, max: BaseValues): this;
3855
+ whereNotBetween<K extends ModelKey<T>>(column: K, min: T[K], max: T[K]): this;
3856
+ whereNotBetween(column: `${string}.${string}`, min: BaseValues, max: BaseValues): this;
3851
3857
  /**
3852
3858
  * @description Adds an AND WHERE NOT BETWEEN condition to the query.
3853
3859
  */
3854
- andWhereNotBetween(column: ModelKey<T>, min: BaseValues, max: BaseValues): this;
3855
- andWhereNotBetween<S extends string>(column: SelectableColumn$1<S>, min: BaseValues, max: BaseValues): this;
3860
+ andWhereNotBetween<K extends ModelKey<T>>(column: K, min: T[K], max: T[K]): this;
3861
+ andWhereNotBetween(column: `${string}.${string}`, min: BaseValues, max: BaseValues): this;
3856
3862
  /**
3857
3863
  * @description Adds an OR WHERE NOT BETWEEN condition to the query.
3858
3864
  */
3859
- orWhereNotBetween(column: ModelKey<T>, min: BaseValues, max: BaseValues): this;
3860
- orWhereNotBetween<S extends string>(column: SelectableColumn$1<S>, min: BaseValues, max: BaseValues): this;
3865
+ orWhereNotBetween<K extends ModelKey<T>>(column: K, min: T[K], max: T[K]): this;
3866
+ orWhereNotBetween(column: `${string}.${string}`, min: BaseValues, max: BaseValues): this;
3861
3867
  /**
3862
3868
  * @description Adds a WHERE LIKE condition to the query.
3863
3869
  */
@@ -3922,38 +3928,44 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
3922
3928
  * @description Adds a WHERE IN condition to the query.
3923
3929
  * @warning If the array is empty, it will add an impossible condition.
3924
3930
  */
3925
- whereIn(column: ModelKey<T>, values: BaseValues[]): this;
3926
- whereIn<S extends string>(column: SelectableColumn$1<S>, values: BaseValues[]): this;
3931
+ whereIn(column: string, values: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3932
+ whereIn<K extends ModelKey<T>>(column: K, values: T[K][]): this;
3933
+ whereIn(column: `${string}.${string}`, values: BaseValues[]): this;
3927
3934
  /**
3928
3935
  * @description Adds an AND WHERE IN condition to the query.
3929
3936
  * @warning If the array is empty, it will add an impossible condition.
3930
3937
  */
3931
- andWhereIn(column: ModelKey<T>, values: BaseValues[]): this;
3932
- andWhereIn<S extends string>(column: SelectableColumn$1<S>, values: BaseValues[]): this;
3938
+ andWhereIn(column: string, values: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3939
+ andWhereIn<K extends ModelKey<T>>(column: K, values: T[K][]): this;
3940
+ andWhereIn(column: `${string}.${string}`, values: BaseValues[]): this;
3933
3941
  /**
3934
3942
  * @description Adds an OR WHERE IN condition to the query.
3935
3943
  * @warning If the array is empty, it will add an impossible condition.
3936
3944
  */
3937
- orWhereIn(column: ModelKey<T>, values: BaseValues[]): this;
3938
- orWhereIn<S extends string>(column: SelectableColumn$1<S>, values: BaseValues[]): this;
3945
+ orWhereIn(column: string, values: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3946
+ orWhereIn<K extends ModelKey<T>>(column: K, values: T[K][]): this;
3947
+ orWhereIn(column: `${string}.${string}`, values: BaseValues[]): this;
3939
3948
  /**
3940
3949
  * @description Adds a WHERE NOT IN condition to the query.
3941
3950
  * @warning If the array is empty, it will add an obvious condition to make it true.
3942
3951
  */
3943
- whereNotIn(column: ModelKey<T>, values: BaseValues[]): this;
3944
- whereNotIn<S extends string>(column: SelectableColumn$1<S>, values: BaseValues[]): this;
3952
+ whereNotIn(column: string, values: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3953
+ whereNotIn<K extends ModelKey<T>>(column: K, values: T[K][]): this;
3954
+ whereNotIn(column: `${string}.${string}`, values: BaseValues[]): this;
3945
3955
  /**
3946
3956
  * @description Adds an OR WHERE NOT IN condition to the query.
3947
3957
  * @warning If the array is empty, it will add an obvious condition to make it true.
3948
3958
  */
3949
- andWhereNotIn(column: ModelKey<T>, values: BaseValues[]): this;
3950
- andWhereNotIn<S extends string>(column: SelectableColumn$1<S>, values: BaseValues[]): this;
3959
+ andWhereNotIn(column: string, values: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3960
+ andWhereNotIn<K extends ModelKey<T>>(column: K, values: T[K][]): this;
3961
+ andWhereNotIn(column: `${string}.${string}`, values: BaseValues[]): this;
3951
3962
  /**
3952
3963
  * @description Adds an OR WHERE NOT IN condition to the query.
3953
3964
  * @warning If the array is empty, it will add an obvious condition to make it true.
3954
3965
  */
3955
- orWhereNotIn(column: ModelKey<T>, values: BaseValues[]): this;
3956
- orWhereNotIn<S extends string>(column: SelectableColumn$1<S>, values: BaseValues[]): this;
3966
+ orWhereNotIn(column: string, values: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void)): this;
3967
+ orWhereNotIn<K extends ModelKey<T>>(column: K, values: T[K][]): this;
3968
+ orWhereNotIn(column: `${string}.${string}`, values: BaseValues[]): this;
3957
3969
  /**
3958
3970
  * @description Adds a WHERE NULL condition to the query.
3959
3971
  */
@@ -4065,18 +4077,25 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
4065
4077
  /**
4066
4078
  * @description Adds a HAVING condition to the query.
4067
4079
  */
4068
- having<S extends string>(column: SelectableColumn$1<S>, value: any): this;
4069
- having(column: ModelKey<T>, operator: BinaryOperatorType, value: any): this;
4080
+ having<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
4081
+ having<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType, value: WhereColumnValue<T, K>): this;
4082
+ having(column: `${string}.${string}`, value: any): this;
4083
+ having(column: `${string}.${string}`, operator: BinaryOperatorType, value: any): this;
4070
4084
  /**
4071
4085
  * @description Adds an AND HAVING condition to the query.
4072
4086
  */
4073
- andHaving<S extends string>(column: SelectableColumn$1<S>, value: any): this;
4087
+ andHaving<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
4088
+ andHaving<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType, value: WhereColumnValue<T, K>): this;
4089
+ andHaving(column: `${string}.${string}`, value: any): this;
4090
+ andHaving(column: `${string}.${string}`, operator: BinaryOperatorType, value: any): this;
4074
4091
  andHaving(column: ModelKey<T>, operator: BinaryOperatorType, value: any): this;
4075
4092
  /**
4076
4093
  * @description Adds an OR HAVING condition to the query.
4077
4094
  */
4078
- orHaving<S extends string>(column: SelectableColumn$1<S>, value: any): this;
4079
- orHaving(column: ModelKey<T>, operator: BinaryOperatorType, value: any): this;
4095
+ orHaving<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
4096
+ orHaving<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType, value: WhereColumnValue<T, K>): this;
4097
+ orHaving(column: `${string}.${string}`, value: any): this;
4098
+ orHaving(column: `${string}.${string}`, operator: BinaryOperatorType, value: any): this;
4080
4099
  /**
4081
4100
  * @description Adds a raw HAVING condition to the query.
4082
4101
  */
@@ -4534,19 +4553,19 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
4534
4553
  update(data: Partial<ModelWithoutRelations<T>>, options?: UpdateOptions): WriteOperation<number>;
4535
4554
  softDelete(options?: SoftDeleteOptions<T>): WriteOperation<number>;
4536
4555
  delete(options?: DeleteOptions): WriteOperation<number>;
4537
- getCount(column?: string, options?: {
4556
+ getCount(column?: (ModelKey<T> & string) | "*" | (string & {}), options?: {
4538
4557
  ignoreHooks: boolean;
4539
4558
  }): Promise<number>;
4540
- getMax(column: string, options?: {
4559
+ getMax(column: (ModelKey<T> & string) | (string & {}), options?: {
4541
4560
  ignoreHooks: boolean;
4542
4561
  }): Promise<number>;
4543
- getMin(column: string, options?: {
4562
+ getMin(column: (ModelKey<T> & string) | (string & {}), options?: {
4544
4563
  ignoreHooks: boolean;
4545
4564
  }): Promise<number>;
4546
- getAvg(column: string, options?: {
4565
+ getAvg(column: (ModelKey<T> & string) | (string & {}), options?: {
4547
4566
  ignoreHooks: boolean;
4548
4567
  }): Promise<number>;
4549
- getSum(column: string, options?: {
4568
+ getSum(column: (ModelKey<T> & string) | (string & {}), options?: {
4550
4569
  ignoreHooks: boolean;
4551
4570
  }): Promise<number>;
4552
4571
  paginate(page: number, perPage: number, options?: {
@@ -6044,6 +6063,11 @@ type WhereType<T> = BaseWhereType<T> & {
6044
6063
  type ModelKey<T extends Model> = {
6045
6064
  [K in keyof T]: T[K] extends NullableAndUndefinable<Model> | NullableAndUndefinable<Model[]> ? never : K extends "*" ? never : T[K] extends (...args: any[]) => any ? never : K;
6046
6065
  }[keyof T];
6066
+ /**
6067
+ * Extracts the value type for a model column key, adding `null` for SQL compatibility.
6068
+ * Used in type-safe where/having clauses to infer value types from column keys.
6069
+ */
6070
+ type WhereColumnValue<T extends Model, K extends ModelKey<T>> = T[K] | null;
6047
6071
  type ModelRelation<T extends Model> = OnlyRelations<T>;
6048
6072
  type OrderByChoices = "asc" | "desc";
6049
6073
  type OrderByType<T extends Model> = {