@@ -28,7 +28,6 @@ import { WrongMethodException } from '#src/exceptions/WrongMethodException'
28
28
import { MONGO_OPERATIONS_DICTIONARY } from '#src/constants/MongoOperationsDictionary'
29
29
import { NotConnectedDatabaseException } from '#src/exceptions/NotConnectedDatabaseException'
30
30
import { NotImplementedMethodException } from '#src/exceptions/NotImplementedMethodException'
31
- import { ObjectId } from '#src/helpers/ObjectId'
32
31
33
32
export class MongoDriver extends Driver < Connection , Collection > {
34
33
public primaryKey = '_id'
@@ -1145,23 +1144,19 @@ export class MongoDriver extends Driver<Connection, Collection> {
1145
1144
}
1146
1145
1147
1146
if ( operation === undefined ) {
1148
- this . _where . push ( this . parseObjectIDToString ( statement ) )
1147
+ this . _where . push ( statement )
1149
1148
1150
1149
return this
1151
1150
}
1152
1151
1153
1152
if ( value === undefined ) {
1154
- operation = this . parseObjectIDToString ( operation )
1155
-
1156
1153
this . _where . push ( {
1157
1154
[ statement ] : this . setOperator ( operation , '=' )
1158
1155
} )
1159
1156
1160
1157
return this
1161
1158
}
1162
1159
1163
- value = this . parseObjectIDToString ( value )
1164
-
1165
1160
this . _where . push ( { [ statement ] : this . setOperator ( value , operation ) } )
1166
1161
1167
1162
return this
@@ -1216,8 +1211,6 @@ export class MongoDriver extends Driver<Connection, Collection> {
1216
1211
* Set a where in statement in your query.
1217
1212
*/
1218
1213
public whereIn ( column : string , values : any [ ] ) {
1219
- values = this . parseObjectIDToString ( values )
1220
-
1221
1214
this . _where . push ( { [ column ] : { $in : values } } )
1222
1215
1223
1216
return this
@@ -1227,8 +1220,6 @@ export class MongoDriver extends Driver<Connection, Collection> {
1227
1220
* Set a where not in statement in your query.
1228
1221
*/
1229
1222
public whereNotIn ( column : string , values : any [ ] ) {
1230
- values = this . parseObjectIDToString ( values )
1231
-
1232
1223
this . _where . push ( { [ column ] : { $nin : values } } )
1233
1224
1234
1225
return this
@@ -1238,8 +1229,6 @@ export class MongoDriver extends Driver<Connection, Collection> {
1238
1229
* Set a where between statement in your query.
1239
1230
*/
1240
1231
public whereBetween ( column : string , values : [ any , any ] ) {
1241
- values = this . parseObjectIDToString ( values )
1242
-
1243
1232
this . _where . push ( { [ column ] : { $gte : values [ 0 ] , $lte : values [ 1 ] } } )
1244
1233
1245
1234
return this
@@ -1249,8 +1238,6 @@ export class MongoDriver extends Driver<Connection, Collection> {
1249
1238
* Set a where not between statement in your query.
1250
1239
*/
1251
1240
public whereNotBetween ( column : string , values : [ any , any ] ) {
1252
- values = this . parseObjectIDToString ( values )
1253
-
1254
1241
this . _where . push ( {
1255
1242
[ column ] : { $not : { $gte : values [ 0 ] , $lte : values [ 1 ] } }
1256
1243
} )
@@ -1291,21 +1278,17 @@ export class MongoDriver extends Driver<Connection, Collection> {
1291
1278
}
1292
1279
1293
1280
if ( operation === undefined ) {
1294
- this . _orWhere . push ( this . parseObjectIDToString ( statement ) )
1281
+ this . _orWhere . push ( statement )
1295
1282
1296
1283
return this
1297
1284
}
1298
1285
1299
1286
if ( value === undefined ) {
1300
- operation = this . parseObjectIDToString ( operation )
1301
-
1302
1287
this . _orWhere . push ( { [ statement ] : this . setOperator ( operation , '=' ) } )
1303
1288
1304
1289
return this
1305
1290
}
1306
1291
1307
- value = this . parseObjectIDToString ( value )
1308
-
1309
1292
this . _orWhere . push ( { [ statement ] : this . setOperator ( value , operation ) } )
1310
1293
1311
1294
return this
@@ -1360,8 +1343,6 @@ export class MongoDriver extends Driver<Connection, Collection> {
1360
1343
* Set an or where in statement in your query.
1361
1344
*/
1362
1345
public orWhereIn ( column : string , values : any [ ] ) {
1363
- values = this . parseObjectIDToString ( values )
1364
-
1365
1346
this . _orWhere . push ( { [ column ] : { $in : values } } )
1366
1347
1367
1348
return this
@@ -1371,8 +1352,6 @@ export class MongoDriver extends Driver<Connection, Collection> {
1371
1352
* Set an or where not in statement in your query.
1372
1353
*/
1373
1354
public orWhereNotIn ( column : string , values : any [ ] ) {
1374
- values = this . parseObjectIDToString ( values )
1375
-
1376
1355
this . _orWhere . push ( { [ column ] : { $nin : values } } )
1377
1356
1378
1357
return this
@@ -1382,8 +1361,6 @@ export class MongoDriver extends Driver<Connection, Collection> {
1382
1361
* Set an or where between statement in your query.
1383
1362
*/
1384
1363
public orWhereBetween ( column : string , values : [ any , any ] ) {
1385
- values = this . parseObjectIDToString ( values )
1386
-
1387
1364
this . _orWhere . push ( { [ column ] : { $gte : values [ 0 ] , $lte : values [ 1 ] } } )
1388
1365
1389
1366
return this
@@ -1393,8 +1370,6 @@ export class MongoDriver extends Driver<Connection, Collection> {
1393
1370
* Set an or where not between statement in your query.
1394
1371
*/
1395
1372
public orWhereNotBetween ( column : string , values : [ any , any ] ) {
1396
- values = this . parseObjectIDToString ( values )
1397
-
1398
1373
this . _orWhere . push ( {
1399
1374
[ column ] : { $not : { $gte : values [ 0 ] , $lte : values [ 1 ] } }
1400
1375
} )
@@ -1565,23 +1540,4 @@ export class MongoDriver extends Driver<Connection, Collection> {
1565
1540
1566
1541
return pipeline
1567
1542
}
1568
-
1569
- /**
1570
- * Parse a valid ObjectID string to an ObjectID object.
1571
- */
1572
- private parseObjectIDToString ( statement : unknown | string ) {
1573
- if ( Is . Array ( statement ) ) {
1574
- return statement . map ( value => this . parseObjectIDToString ( value ) )
1575
- }
1576
-
1577
- if ( Is . Object ( statement ) ) {
1578
- Object . keys ( statement ) . forEach ( key => {
1579
- statement [ key ] = ObjectId . ifValidSwap ( statement [ key ] )
1580
- } )
1581
-
1582
- return statement
1583
- }
1584
-
1585
- return ObjectId . ifValidSwap ( statement )
1586
- }
1587
1543
}
0 commit comments