@chevre/domain 21.8.0-alpha.34 → 21.8.0-alpha.35
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.
|
@@ -26,9 +26,10 @@ import { BulkWriteResult as BulkWriteOpResultObject } from 'mongodb';
|
|
|
26
26
|
import { AnyExpression, Connection, PipelineStage } from 'mongoose';
|
|
27
27
|
import * as factory from '../factory';
|
|
28
28
|
type IMatchStage = PipelineStage.Match;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
type KeyOfUnitPriceOffer = keyof factory.unitPriceOffer.IUnitPriceOffer;
|
|
30
|
+
type IProjection = {
|
|
31
|
+
[key in KeyOfUnitPriceOffer]?: 0 | 1;
|
|
32
|
+
};
|
|
32
33
|
/**
|
|
33
34
|
* オファーリポジトリ
|
|
34
35
|
*/
|
package/lib/chevre/repo/offer.js
CHANGED
|
@@ -959,7 +959,7 @@ class MongoRepository {
|
|
|
959
959
|
// 上書き禁止属性を除外
|
|
960
960
|
const { id, identifier, project, typeOf } = params, updateFields = __rest(params, ["id", "identifier", "project", "typeOf"]);
|
|
961
961
|
savedUnitPriceOffer = Object.assign(Object.assign({}, updateFields), { id: originalUnitPriceOffer.id, identifier: originalUnitPriceOffer.identifier, project: originalUnitPriceOffer.project, typeOf: originalUnitPriceOffer.typeOf });
|
|
962
|
-
doc = yield this.
|
|
962
|
+
doc = yield this.aggregateOfferModel.findOneAndUpdate({ 'offers.id': params.id }, {
|
|
963
963
|
$set: {
|
|
964
964
|
'offers.$[offer]': savedUnitPriceOffer
|
|
965
965
|
}
|
|
@@ -1083,6 +1083,40 @@ class MongoRepository {
|
|
|
1083
1083
|
// TODO USE_AGGREGATE_OFFERS_AS_PRIMARY対応(2023-09-05~)
|
|
1084
1084
|
if (settings_1.USE_AGGREGATE_OFFERS_AS_PRIMARY) {
|
|
1085
1085
|
throw new factory.errors.NotImplemented('USE_AGGREGATE_OFFERS_AS_PRIMARY not implemented');
|
|
1086
|
+
// const conditions: any = {
|
|
1087
|
+
// 'project.id': { $eq: params.project.id },
|
|
1088
|
+
// 'offers.addOn.itemOffered.id': { $exists: true, $in: params.addOn.itemOffered.id.$in }
|
|
1089
|
+
// };
|
|
1090
|
+
// const updatingOffers = <Pick<factory.unitPriceOffer.IUnitPriceOffer, 'id'>[]>await this.searchFromAggregateOffer(
|
|
1091
|
+
// {
|
|
1092
|
+
// project: { id: { $eq: params.project.id } },
|
|
1093
|
+
// addOn: { itemOffered: { id: { $in: params.addOn.itemOffered.id.$in } } }
|
|
1094
|
+
// },
|
|
1095
|
+
// { id: 1 }
|
|
1096
|
+
// );
|
|
1097
|
+
// const result = await this.aggregateOfferModel.updateMany(
|
|
1098
|
+
// conditions,
|
|
1099
|
+
// {
|
|
1100
|
+
// $pull: {
|
|
1101
|
+
// 'offers.addOn': {
|
|
1102
|
+
// 'itemOffered.id': { $in: params.addOn.itemOffered.id.$in }
|
|
1103
|
+
// }
|
|
1104
|
+
// }
|
|
1105
|
+
// }
|
|
1106
|
+
// )
|
|
1107
|
+
// .exec();
|
|
1108
|
+
// // 同期タスク作成(2023-09-05~)
|
|
1109
|
+
// if (updatingOffers.length > 0) {
|
|
1110
|
+
// await this.saveSyncTask({
|
|
1111
|
+
// project: { id: params.project.id },
|
|
1112
|
+
// id: { $in: updatingOffers.map((offer) => String(offer.id)) },
|
|
1113
|
+
// identifier: { $in: [] },
|
|
1114
|
+
// isDeleted: false,
|
|
1115
|
+
// typeOf: factory.offerType.AggregateOffer,
|
|
1116
|
+
// options: { emitImmediately: true }
|
|
1117
|
+
// });
|
|
1118
|
+
// }
|
|
1119
|
+
// return result;
|
|
1086
1120
|
}
|
|
1087
1121
|
else {
|
|
1088
1122
|
const conditions = {
|
|
@@ -1117,13 +1151,22 @@ class MongoRepository {
|
|
|
1117
1151
|
}
|
|
1118
1152
|
deleteById(params) {
|
|
1119
1153
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1120
|
-
//
|
|
1121
|
-
// TODO USE_AGGREGATE_OFFERS_AS_PRIMARY対応(2023-09-05~)
|
|
1154
|
+
// USE_AGGREGATE_OFFERS_AS_PRIMARY対応(2023-09-05~)
|
|
1122
1155
|
if (settings_1.USE_AGGREGATE_OFFERS_AS_PRIMARY) {
|
|
1123
|
-
|
|
1156
|
+
yield this.aggregateOfferModel.findOneAndRemove({ _id: { $eq: params.id } }, { projection: { _id: 1 } })
|
|
1157
|
+
.exec();
|
|
1158
|
+
// 同期タスク作成(2023-09-03~)
|
|
1159
|
+
yield this.saveSyncTask({
|
|
1160
|
+
project: { id: params.project.id },
|
|
1161
|
+
id: { $in: [params.id] },
|
|
1162
|
+
identifier: { $in: [] },
|
|
1163
|
+
isDeleted: true,
|
|
1164
|
+
typeOf: factory.offerType.AggregateOffer,
|
|
1165
|
+
options: { emitImmediately: true }
|
|
1166
|
+
});
|
|
1124
1167
|
}
|
|
1125
1168
|
else {
|
|
1126
|
-
yield this.offerModel.findOneAndRemove({ _id: params.id }, { projection: { _id: 1 } })
|
|
1169
|
+
yield this.offerModel.findOneAndRemove({ _id: { $eq: params.id } }, { projection: { _id: 1 } })
|
|
1127
1170
|
.exec();
|
|
1128
1171
|
// 同期タスク作成(2023-09-03~)
|
|
1129
1172
|
yield this.saveSyncTask({
|
|
@@ -1248,7 +1291,13 @@ class MongoRepository {
|
|
|
1248
1291
|
const idIn = (_c = params.id) === null || _c === void 0 ? void 0 : _c.$in;
|
|
1249
1292
|
const identifierIn = (_d = params.identifier) === null || _d === void 0 ? void 0 : _d.$in;
|
|
1250
1293
|
if (params.isDeleted === true) {
|
|
1251
|
-
|
|
1294
|
+
if (Array.isArray(idIn) && idIn.length > 0) {
|
|
1295
|
+
yield this.offerModel.deleteMany({
|
|
1296
|
+
'project.id': { $eq: params.project.id },
|
|
1297
|
+
_id: { $in: idIn }
|
|
1298
|
+
})
|
|
1299
|
+
.exec();
|
|
1300
|
+
}
|
|
1252
1301
|
}
|
|
1253
1302
|
else {
|
|
1254
1303
|
let aggregateOffers = [];
|
|
@@ -1256,8 +1305,7 @@ class MongoRepository {
|
|
|
1256
1305
|
aggregateOffers = yield this.aggregateOfferModel.aggregate([
|
|
1257
1306
|
{
|
|
1258
1307
|
$unwind: {
|
|
1259
|
-
path: '$offers'
|
|
1260
|
-
includeArrayIndex: OFFERS_ARRAY_INDEX_NAME
|
|
1308
|
+
path: '$offers'
|
|
1261
1309
|
}
|
|
1262
1310
|
},
|
|
1263
1311
|
{
|
package/package.json
CHANGED