You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Drivers/MongoDriver.ts
+14-4Lines changed: 14 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -27,9 +27,7 @@ export class MongoDriver implements DriverContract {
27
27
28
28
privateclient: Connection
29
29
privatesession: ClientSession
30
-
privatequeryBuilder: Collection
31
30
privateisConnected: boolean
32
-
33
31
privatereadonlyconfigs: any
34
32
privatereadonlyconnection: string
35
33
@@ -53,6 +51,18 @@ export class MongoDriver implements DriverContract {
53
51
this.isConnected=true
54
52
}
55
53
54
+
private_queryBuilder: Collection
55
+
56
+
privategetqueryBuilder(){
57
+
if(!this._queryBuilder){
58
+
thrownewInternalServerException(
59
+
`Query builder does not exist in ${MongoDriver.name}, this usually happens when you don't have called connect method to create the connection with database`,
60
+
)
61
+
}
62
+
63
+
returnthis._queryBuilder
64
+
}
65
+
56
66
// This is important only for update and delete queries
57
67
private_where={}
58
68
@@ -248,7 +258,7 @@ export class MongoDriver implements DriverContract {
@@ -37,11 +35,23 @@ export class MySqlDriver implements DriverContract {
37
35
38
36
this.client=client
39
37
this.isConnected=true
40
-
this.queryBuilder=this.query()
38
+
this._queryBuilder=this.query()
39
+
}
40
+
41
+
private_queryBuilder: Knex.QueryBuilder
42
+
43
+
privategetqueryBuilder(){
44
+
if(!this._queryBuilder){
45
+
thrownewInternalServerException(
46
+
`Query builder does not exist in ${MySqlDriver.name}, this usually happens when you don't have called connect method to create the connection with database`,
47
+
)
48
+
}
49
+
50
+
returnthis._queryBuilder
41
51
}
42
52
43
53
setQueryBuilder(query: any){
44
-
this.queryBuilder=query.client
54
+
this._queryBuilder=query.client
45
55
}
46
56
47
57
query(){
@@ -71,7 +81,7 @@ export class MySqlDriver implements DriverContract {
71
81
]
72
82
73
83
if(protectedMethods.includes(propertyKey)){
74
-
this.queryBuilder=this.query()
84
+
this._queryBuilder=this.query()
75
85
}
76
86
77
87
returntarget[propertyKey]
@@ -92,7 +102,7 @@ export class MySqlDriver implements DriverContract {
92
102
constcommittedTrx=awaitclient.commit(value)
93
103
94
104
this.client=null
95
-
this.queryBuilder=null
105
+
this._queryBuilder=null
96
106
97
107
returncommittedTrx
98
108
}
@@ -108,7 +118,7 @@ export class MySqlDriver implements DriverContract {
108
118
constrolledBackTrx=awaitclient.rollback(error)
109
119
110
120
this.client=null
111
-
this.queryBuilder=null
121
+
this._queryBuilder=null
112
122
113
123
returnrolledBackTrx
114
124
}
@@ -126,7 +136,7 @@ export class MySqlDriver implements DriverContract {
126
136
this.configs,
127
137
saveOnDriver,
128
138
)
129
-
this.queryBuilder=this.query()
139
+
this._queryBuilder=this.query()
130
140
131
141
this.isConnected=true
132
142
}
@@ -189,7 +199,7 @@ export class MySqlDriver implements DriverContract {
189
199
190
200
this.client=null
191
201
this.isConnected=false
192
-
this.queryBuilder=null
202
+
this._queryBuilder=null
193
203
this.defaultTable=null
194
204
}
195
205
@@ -220,7 +230,7 @@ export class MySqlDriver implements DriverContract {
220
230
asyncfindMany(): Promise<any[]>{
221
231
constdata=awaitthis.queryBuilder
222
232
223
-
this.queryBuilder=this.query()
233
+
this._queryBuilder=this.query()
224
234
225
235
returndata
226
236
}
@@ -316,25 +326,25 @@ export class MySqlDriver implements DriverContract {
0 commit comments