@chevre/domain 21.18.0-alpha.3 → 21.18.0-alpha.4

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.
@@ -35,11 +35,17 @@ export declare class MongoRepository {
35
35
  private readonly offerCatalogModel;
36
36
  constructor(connection: Connection);
37
37
  static CREATE_MONGO_CONDITIONS(params: factory.offerCatalog.ISearchConditions): any[];
38
- save(params: factory.offerCatalog.IOfferCatalog): Promise<factory.offerCatalog.IOfferCatalog>;
38
+ save(params: factory.offerCatalog.IOfferCatalog & {
39
+ $unset?: any;
40
+ }): Promise<{
41
+ id: string;
42
+ }>;
39
43
  /**
40
44
  * プロジェクトとコードから冪等保管
41
45
  */
42
- saveByIdentifier(params: factory.offerCatalog.IOfferCatalog): Promise<factory.offerCatalog.IOfferCatalog>;
46
+ saveByIdentifier(params: factory.offerCatalog.IOfferCatalog): Promise<{
47
+ id: string;
48
+ }>;
43
49
  /**
44
50
  * 同期日時を更新する
45
51
  */
@@ -133,13 +133,13 @@ class MongoRepository {
133
133
  let doc;
134
134
  if (params.id === '') {
135
135
  const uniqid = yield Promise.resolve().then(() => require('uniqid'));
136
- const id = uniqid();
137
- doc = yield this.offerCatalogModel.create(Object.assign(Object.assign({}, params), { _id: id }));
136
+ const newId = uniqid();
137
+ const { id, $unset } = params, creatingDoc = __rest(params, ["id", "$unset"]);
138
+ doc = yield this.offerCatalogModel.create(Object.assign(Object.assign({}, creatingDoc), { _id: newId }));
138
139
  }
139
140
  else {
140
- // 上書き禁止属性を除外(2022-08-24~)
141
- const { id, identifier, project, typeOf } = params, updateFields = __rest(params, ["id", "identifier", "project", "typeOf"]);
142
- doc = yield this.offerCatalogModel.findOneAndUpdate({ _id: params.id }, updateFields, { upsert: false, new: true })
141
+ const { id, identifier, itemOffered, project, typeOf, $unset } = params, updateFields = __rest(params, ["id", "identifier", "itemOffered", "project", "typeOf", "$unset"]); // 上書き禁止属性を除外
142
+ doc = yield this.offerCatalogModel.findOneAndUpdate({ _id: { $eq: params.id } }, Object.assign({ $set: updateFields }, (params.$unset !== undefined) ? { $unset: params.$unset } : undefined), { upsert: false, new: true, projection: { _id: 1 } })
143
143
  .exec();
144
144
  }
145
145
  if (doc === null) {
@@ -155,14 +155,14 @@ class MongoRepository {
155
155
  return __awaiter(this, void 0, void 0, function* () {
156
156
  const uniqid = yield Promise.resolve().then(() => require('uniqid'));
157
157
  const newId = uniqid();
158
- const { id, identifier, project, typeOf } = params, updateFields = __rest(params, ["id", "identifier", "project", "typeOf"]);
158
+ const { id, identifier, itemOffered, project, typeOf } = params, updateFields = __rest(params, ["id", "identifier", "itemOffered", "project", "typeOf"]);
159
159
  const doc = yield this.offerCatalogModel.findOneAndUpdate({
160
160
  identifier: { $eq: params.identifier },
161
161
  'project.id': { $eq: params.project.id }
162
162
  }, {
163
163
  $set: updateFields,
164
- $setOnInsert: { _id: newId, identifier, project, typeOf }
165
- }, { upsert: true, new: true })
164
+ $setOnInsert: { _id: newId, identifier, itemOffered, project, typeOf }
165
+ }, { upsert: true, new: true, projection: { _id: 1 } })
166
166
  .exec();
167
167
  return doc.toObject();
168
168
  });
package/package.json CHANGED
@@ -115,5 +115,5 @@
115
115
  "postversion": "git push origin --tags",
116
116
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
117
117
  },
118
- "version": "21.18.0-alpha.3"
118
+ "version": "21.18.0-alpha.4"
119
119
  }