Skip to content

Commit 1d45295

Browse files
committed
fix: remove modifiedCount from MongoDriver
1 parent 206af5c commit 1d45295

3 files changed

Lines changed: 9 additions & 33 deletions

File tree

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@secjs/database",
3-
"version": "1.1.4",
3+
"version": "1.1.5",
44
"description": "Handle your application database with factories, seeders and query builder in Node.js",
55
"license": "MIT",
66
"author": "João Lenon <lenon@secjs.com.br>",
@@ -48,7 +48,7 @@
4848
"husky": "3.0.9",
4949
"jest": "27.1.0",
5050
"lint-staged": "9.4.3",
51-
"mongodb-memory-server": "8.4.0",
51+
"mongodb-memory-server": "^8.4.0",
5252
"prettier": "2.0.5",
5353
"reflect-metadata": "0.1.13",
5454
"ts-jest": "27.0.5",

src/Drivers/MongoDriver.ts

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -298,37 +298,25 @@ export class MongoDriver implements DriverContract {
298298
key[k] = MongoDriver.stringToObjectId(key[k])
299299
})
300300

301-
const { modifiedCount } = await this.queryBuilder.updateMany(
301+
await this.queryBuilder.updateMany(
302302
this._where,
303303
{ $set: key },
304304
{ upsert: false },
305305
)
306306

307-
if (!modifiedCount) {
308-
this._where = {}
309-
310-
return []
311-
}
312-
313307
const data = await this.queryBuilder.find(this.where).toArray()
314308

315309
return data.map(model => model._id.toString())
316310
}
317311

318312
value = MongoDriver.stringToObjectId(value)
319313

320-
const { modifiedCount } = await this.queryBuilder.updateMany(
314+
await this.queryBuilder.updateMany(
321315
this._where,
322316
{ $set: { [key]: value } },
323317
{ upsert: false },
324318
)
325319

326-
if (!modifiedCount) {
327-
this._where = {}
328-
329-
return []
330-
}
331-
332320
const data = await this.queryBuilder.find(this.where).toArray()
333321

334322
return data.map(model => model._id.toString())
@@ -340,35 +328,23 @@ export class MongoDriver implements DriverContract {
340328
key[k] = MongoDriver.stringToObjectId(key[k])
341329
})
342330

343-
const { modifiedCount } = await this.queryBuilder.updateMany(
331+
await this.queryBuilder.updateMany(
344332
this._where,
345333
{ $set: key },
346334
{ upsert: false },
347335
)
348336

349-
if (!modifiedCount) {
350-
this._where = {}
351-
352-
return []
353-
}
354-
355337
return this.queryBuilder.find(this.where).toArray()
356338
}
357339

358340
value = MongoDriver.stringToObjectId(value)
359341

360-
const { modifiedCount } = await this.queryBuilder.updateMany(
342+
await this.queryBuilder.updateMany(
361343
this._where,
362344
{ $set: { [key]: value } },
363345
{ upsert: false },
364346
)
365347

366-
if (!modifiedCount) {
367-
this._where = {}
368-
369-
return []
370-
}
371-
372348
return this.queryBuilder.find(this.where).toArray()
373349
}
374350

0 commit comments

Comments
 (0)