Skip to content

Commit 59d40f2

Browse files
authored
Merge pull request #190 from AthennaIO/develop
chore(npm): update dependencies
2 parents ba72cd2 + 406ab1b commit 59d40f2

File tree

3 files changed

+5
-49
lines changed

3 files changed

+5
-49
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

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

src/database/drivers/MongoDriver.ts

+2-46
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import { WrongMethodException } from '#src/exceptions/WrongMethodException'
2828
import { MONGO_OPERATIONS_DICTIONARY } from '#src/constants/MongoOperationsDictionary'
2929
import { NotConnectedDatabaseException } from '#src/exceptions/NotConnectedDatabaseException'
3030
import { NotImplementedMethodException } from '#src/exceptions/NotImplementedMethodException'
31-
import { ObjectId } from '#src/helpers/ObjectId'
3231

3332
export class MongoDriver extends Driver<Connection, Collection> {
3433
public primaryKey = '_id'
@@ -1145,23 +1144,19 @@ export class MongoDriver extends Driver<Connection, Collection> {
11451144
}
11461145

11471146
if (operation === undefined) {
1148-
this._where.push(this.parseObjectIDToString(statement))
1147+
this._where.push(statement)
11491148

11501149
return this
11511150
}
11521151

11531152
if (value === undefined) {
1154-
operation = this.parseObjectIDToString(operation)
1155-
11561153
this._where.push({
11571154
[statement]: this.setOperator(operation, '=')
11581155
})
11591156

11601157
return this
11611158
}
11621159

1163-
value = this.parseObjectIDToString(value)
1164-
11651160
this._where.push({ [statement]: this.setOperator(value, operation) })
11661161

11671162
return this
@@ -1216,8 +1211,6 @@ export class MongoDriver extends Driver<Connection, Collection> {
12161211
* Set a where in statement in your query.
12171212
*/
12181213
public whereIn(column: string, values: any[]) {
1219-
values = this.parseObjectIDToString(values)
1220-
12211214
this._where.push({ [column]: { $in: values } })
12221215

12231216
return this
@@ -1227,8 +1220,6 @@ export class MongoDriver extends Driver<Connection, Collection> {
12271220
* Set a where not in statement in your query.
12281221
*/
12291222
public whereNotIn(column: string, values: any[]) {
1230-
values = this.parseObjectIDToString(values)
1231-
12321223
this._where.push({ [column]: { $nin: values } })
12331224

12341225
return this
@@ -1238,8 +1229,6 @@ export class MongoDriver extends Driver<Connection, Collection> {
12381229
* Set a where between statement in your query.
12391230
*/
12401231
public whereBetween(column: string, values: [any, any]) {
1241-
values = this.parseObjectIDToString(values)
1242-
12431232
this._where.push({ [column]: { $gte: values[0], $lte: values[1] } })
12441233

12451234
return this
@@ -1249,8 +1238,6 @@ export class MongoDriver extends Driver<Connection, Collection> {
12491238
* Set a where not between statement in your query.
12501239
*/
12511240
public whereNotBetween(column: string, values: [any, any]) {
1252-
values = this.parseObjectIDToString(values)
1253-
12541241
this._where.push({
12551242
[column]: { $not: { $gte: values[0], $lte: values[1] } }
12561243
})
@@ -1291,21 +1278,17 @@ export class MongoDriver extends Driver<Connection, Collection> {
12911278
}
12921279

12931280
if (operation === undefined) {
1294-
this._orWhere.push(this.parseObjectIDToString(statement))
1281+
this._orWhere.push(statement)
12951282

12961283
return this
12971284
}
12981285

12991286
if (value === undefined) {
1300-
operation = this.parseObjectIDToString(operation)
1301-
13021287
this._orWhere.push({ [statement]: this.setOperator(operation, '=') })
13031288

13041289
return this
13051290
}
13061291

1307-
value = this.parseObjectIDToString(value)
1308-
13091292
this._orWhere.push({ [statement]: this.setOperator(value, operation) })
13101293

13111294
return this
@@ -1360,8 +1343,6 @@ export class MongoDriver extends Driver<Connection, Collection> {
13601343
* Set an or where in statement in your query.
13611344
*/
13621345
public orWhereIn(column: string, values: any[]) {
1363-
values = this.parseObjectIDToString(values)
1364-
13651346
this._orWhere.push({ [column]: { $in: values } })
13661347

13671348
return this
@@ -1371,8 +1352,6 @@ export class MongoDriver extends Driver<Connection, Collection> {
13711352
* Set an or where not in statement in your query.
13721353
*/
13731354
public orWhereNotIn(column: string, values: any[]) {
1374-
values = this.parseObjectIDToString(values)
1375-
13761355
this._orWhere.push({ [column]: { $nin: values } })
13771356

13781357
return this
@@ -1382,8 +1361,6 @@ export class MongoDriver extends Driver<Connection, Collection> {
13821361
* Set an or where between statement in your query.
13831362
*/
13841363
public orWhereBetween(column: string, values: [any, any]) {
1385-
values = this.parseObjectIDToString(values)
1386-
13871364
this._orWhere.push({ [column]: { $gte: values[0], $lte: values[1] } })
13881365

13891366
return this
@@ -1393,8 +1370,6 @@ export class MongoDriver extends Driver<Connection, Collection> {
13931370
* Set an or where not between statement in your query.
13941371
*/
13951372
public orWhereNotBetween(column: string, values: [any, any]) {
1396-
values = this.parseObjectIDToString(values)
1397-
13981373
this._orWhere.push({
13991374
[column]: { $not: { $gte: values[0], $lte: values[1] } }
14001375
})
@@ -1565,23 +1540,4 @@ export class MongoDriver extends Driver<Connection, Collection> {
15651540

15661541
return pipeline
15671542
}
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-
}
15871543
}

0 commit comments

Comments
 (0)