@travetto/model-mongo 3.3.6 → 3.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/service.ts +7 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/model-mongo",
3
- "version": "3.3.6",
3
+ "version": "3.3.7",
4
4
  "description": "Mongo backing for the travetto model module.",
5
5
  "keywords": [
6
6
  "mongo",
@@ -26,8 +26,8 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@travetto/config": "^3.3.4",
29
- "@travetto/model": "^3.3.6",
30
- "@travetto/model-query": "^3.3.6",
29
+ "@travetto/model": "^3.3.7",
30
+ "@travetto/model-query": "^3.3.7",
31
31
  "mongodb": "^6.1.0"
32
32
  },
33
33
  "peerDependencies": {
package/src/service.ts CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  PageableModelQuery, ValidStringFields, WhereClause, ModelQuerySuggestSupport
15
15
  } from '@travetto/model-query';
16
16
 
17
- import { ShutdownManager, type Class, AppError } from '@travetto/base';
17
+ import { ShutdownManager, type Class, AppError, TypedObject } from '@travetto/base';
18
18
  import { Injectable } from '@travetto/di';
19
19
  import { DeepPartial, FieldConfig, SchemaRegistry, SchemaValidator } from '@travetto/schema';
20
20
 
@@ -249,10 +249,11 @@ export class MongoModelService implements
249
249
  }, {});
250
250
 
251
251
  const id = item.id;
252
+
252
253
  const res = await store.findOneAndUpdate(
253
254
  this.getWhere<ModelType>(cls, { id }),
254
255
  final,
255
- { returnDocument: 'after' }
256
+ { returnDocument: 'after', includeResultMetadata: true }
256
257
  );
257
258
 
258
259
  if (!res.value) {
@@ -373,14 +374,14 @@ export class MongoModelService implements
373
374
  }
374
375
  }
375
376
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
376
- for (const { index, _id } of res.getUpsertedIds() as { index: number, _id: mongo.ObjectId }[]) {
377
- out.insertedIds.set(index, MongoUtil.idToString(_id));
377
+ for (const [index, _id] of TypedObject.entries(res.upsertedIds) as [number, mongo.ObjectId][]) {
378
+ out.insertedIds.set(+index, MongoUtil.idToString(_id));
378
379
  }
379
380
 
380
381
  if (out.counts) {
381
- out.counts.delete = res.nRemoved;
382
+ out.counts.delete = res.deletedCount;
382
383
  out.counts.update = operations.filter(x => x.update).length;
383
- out.counts.insert = res.nInserted;
384
+ out.counts.insert = res.insertedCount;
384
385
  out.counts.upsert = operations.filter(x => x.upsert).length;
385
386
  }
386
387