@@ -741,6 +741,7 @@ export class ModelQueryBuilder<
741741 return this
742742 }
743743
744+ public where ( statement : ( query : this) => void ) : this
744745 public where ( statement : Partial < M > ) : this
745746 public where ( statement : Record < string , any > ) : this
746747 public where ( key : ModelColumns < M > , value : any ) : this
@@ -750,6 +751,21 @@ export class ModelQueryBuilder<
750751 * Set a where statement in your query.
751752 */
752753 public where ( statement : any , operation ?: any | Operations , value ?: any ) {
754+ if ( Is . Function ( statement ) ) {
755+ const driver = this . driver . clone ( )
756+
757+ super . where ( query => {
758+ const modelQb = new ModelQueryBuilder (
759+ this . Model ,
760+ driver . setQueryBuilder ( query , { useSetQB : true } )
761+ )
762+
763+ statement ( modelQb )
764+ } )
765+
766+ return this
767+ }
768+
753769 if ( ! operation ) {
754770 const parsed = this . schema . propertiesToColumnNames ( statement )
755771
@@ -765,6 +781,7 @@ export class ModelQueryBuilder<
765781 return this
766782 }
767783
784+ public whereNot ( statement : ( query : this) => void ) : this
768785 public whereNot ( statement : Partial < M > ) : this
769786 public whereNot ( statement : Record < string , any > ) : this
770787 public whereNot ( key : ModelColumns < M > , value : any ) : this
@@ -773,6 +790,21 @@ export class ModelQueryBuilder<
773790 * Set a where not statement in your query.
774791 */
775792 public whereNot ( statement : any , value ?: any ) {
793+ if ( Is . Function ( statement ) ) {
794+ const driver = this . driver . clone ( )
795+
796+ super . whereNot ( query => {
797+ const modelQb = new ModelQueryBuilder (
798+ this . Model ,
799+ driver . setQueryBuilder ( query , { useSetQB : true } )
800+ )
801+
802+ statement ( modelQb )
803+ } )
804+
805+ return this
806+ }
807+
776808 if ( ! value ) {
777809 const parsed = this . schema . propertiesToColumnNames ( statement )
778810
@@ -876,6 +908,7 @@ export class ModelQueryBuilder<
876908 return this
877909 }
878910
911+ public orWhere ( statement : ( query : this) => void ) : this
879912 public orWhere ( statement : Partial < M > ) : this
880913 public orWhere ( statement : Record < string , any > ) : this
881914 public orWhere ( key : ModelColumns < M > , value : any ) : this
@@ -885,6 +918,21 @@ export class ModelQueryBuilder<
885918 * Set a orWhere statement in your query.
886919 */
887920 public orWhere ( statement : any , operation ?: any | Operations , value ?: any ) {
921+ if ( Is . Function ( statement ) ) {
922+ const driver = this . driver . clone ( )
923+
924+ super . orWhere ( query => {
925+ const modelQb = new ModelQueryBuilder (
926+ this . Model ,
927+ driver . setQueryBuilder ( query , { useSetQB : true } )
928+ )
929+
930+ statement ( modelQb )
931+ } )
932+
933+ return this
934+ }
935+
888936 if ( ! operation ) {
889937 const parsed = this . schema . propertiesToColumnNames ( statement )
890938
@@ -900,6 +948,7 @@ export class ModelQueryBuilder<
900948 return this
901949 }
902950
951+ public orWhereNot ( statement : ( query : this) => void ) : this
903952 public orWhereNot ( statement : Partial < M > ) : this
904953 public orWhereNot ( statement : Record < string , any > ) : this
905954 public orWhereNot ( key : ModelColumns < M > , value : any ) : this
@@ -908,6 +957,21 @@ export class ModelQueryBuilder<
908957 * Set a orWhere not statement in your query.
909958 */
910959 public orWhereNot ( statement : any , value ?: any ) {
960+ if ( Is . Function ( statement ) ) {
961+ const driver = this . driver . clone ( )
962+
963+ super . orWhereNot ( query => {
964+ const modelQb = new ModelQueryBuilder (
965+ this . Model ,
966+ driver . setQueryBuilder ( query , { useSetQB : true } )
967+ )
968+
969+ statement ( modelQb )
970+ } )
971+
972+ return this
973+ }
974+
911975 if ( ! value ) {
912976 const parsed = this . schema . propertiesToColumnNames ( statement )
913977
0 commit comments