@chevre/domain 23.2.0-alpha.31 → 23.2.0-alpha.32

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.
@@ -90,11 +90,11 @@ export declare class EventRepo {
90
90
  */
91
91
  update: boolean;
92
92
  }): Promise<{
93
- bulkWriteResult: BulkWriteResult;
93
+ bulkWriteResult?: BulkWriteResult;
94
94
  modifiedEvents: {
95
95
  id: string;
96
96
  }[];
97
- } | void>;
97
+ }>;
98
98
  /**
99
99
  * イベント部分更新
100
100
  */
@@ -344,15 +344,27 @@ class EventRepo {
344
344
  }
345
345
  if (bulkWriteOps.length > 0) {
346
346
  const bulkWriteResult = yield this.eventModel.bulkWrite(bulkWriteOps, { ordered: false });
347
- // modifiedの場合upsertedIdsに含まれないので、idを検索する
348
- const modifiedEvents = yield this.eventModel.find({ $or: queryFilters }, {
349
- _id: 0,
350
- id: { $toString: '$_id' }
351
- })
352
- .lean()
353
- .exec();
354
- return { bulkWriteResult, modifiedEvents };
347
+ // update:falseの場合、upsertedIdsのみmodifiedEventsとして返せばよい(2026-01-16~)
348
+ if (!update) {
349
+ // BulkWriteResult -> upsertedIds: { '0': '7iri6p4m54k0r3g' }
350
+ return {
351
+ bulkWriteResult,
352
+ modifiedEvents: Object.values(bulkWriteResult.upsertedIds)
353
+ .map((id) => ({ id: String(id) }))
354
+ };
355
+ }
356
+ else {
357
+ // modifiedの場合upsertedIdsに含まれないので、idを検索する
358
+ const modifiedEvents = yield this.eventModel.find({ $or: queryFilters }, {
359
+ _id: 0,
360
+ id: { $toString: '$_id' }
361
+ })
362
+ .lean()
363
+ .exec();
364
+ return { bulkWriteResult, modifiedEvents };
365
+ }
355
366
  }
367
+ return { modifiedEvents: [] };
356
368
  });
357
369
  }
358
370
  /**
package/package.json CHANGED
@@ -116,5 +116,5 @@
116
116
  "postversion": "git push origin --tags",
117
117
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
118
118
  },
119
- "version": "23.2.0-alpha.31"
119
+ "version": "23.2.0-alpha.32"
120
120
  }