Skip to content

Commit da5cc5f

Browse files
authored
Merge pull request #201 from AthennaIO/develop
chore(npm): update dependencies
2 parents 8cb9674 + b095dd1 commit da5cc5f

File tree

4 files changed

+72
-4
lines changed

4 files changed

+72
-4
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@athenna/database",
3-
"version": "5.22.0",
3+
"version": "5.23.0",
44
"description": "The Athenna database handler for SQL/NoSQL.",
55
"license": "MIT",
66
"author": "João Lenon <lenon@athenna.io>",

src/database/builders/QueryBuilder.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class QueryBuilder<
2424
/**
2525
* The drivers responsible for handling database operations.
2626
*/
27-
private driver: Driver
27+
protected driver: Driver
2828

2929
/**
3030
* Creates a new instance of QueryBuilder.
@@ -723,6 +723,7 @@ export class QueryBuilder<
723723
return this
724724
}
725725

726+
public where(statement: (query: this) => void): this
726727
public where(statement: Partial<T>): this
727728
public where(statement: Record<string, any>): this
728729
public where(key: string | ModelColumns<T>, value: any): this
@@ -741,6 +742,7 @@ export class QueryBuilder<
741742
return this
742743
}
743744

745+
public whereNot(statement: (query: this) => void): this
744746
public whereNot(statement: Partial<T>): this
745747
public whereNot(statement: Record<string, any>): this
746748
public whereNot(key: string | ModelColumns<T>, value: any): this
@@ -853,6 +855,7 @@ export class QueryBuilder<
853855
return this
854856
}
855857

858+
public orWhere(statement: (query: this) => void): this
856859
public orWhere(statement: Partial<T>): this
857860
public orWhere(statement: Record<string, any>): this
858861
public orWhere(key: string | ModelColumns<T>, value: any): this
@@ -871,6 +874,7 @@ export class QueryBuilder<
871874
return this
872875
}
873876

877+
public orWhereNot(statement: (query: this) => void): this
874878
public orWhereNot(statement: Partial<T>): this
875879
public orWhereNot(statement: Record<string, any>): this
876880
public orWhereNot(key: string | ModelColumns<T>, value: any): this

src/models/builders/ModelQueryBuilder.ts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)