@chevre/domain 21.8.0-alpha.48 → 21.8.0-alpha.49
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.
|
@@ -34,33 +34,47 @@ async function main() {
|
|
|
34
34
|
<chevre.factory.unitPriceOffer.IUnitPriceOffer & { _id: string }>doc.toObject();
|
|
35
35
|
|
|
36
36
|
let alreadyMigrated = false;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
37
|
+
const aggregateOffer = await offerRepo.findAggregateOfferById({
|
|
38
|
+
project: { id: unitPriceOffer.project.id },
|
|
39
|
+
id: String(unitPriceOffer.id)
|
|
40
|
+
});
|
|
41
|
+
let offerByAggregateOffer = aggregateOffer.offers.shift();
|
|
42
|
+
// alreadyMigrated = true;
|
|
43
|
+
console.log(unitPriceOffer, offerByAggregateOffer);
|
|
44
|
+
|
|
45
|
+
// 比較のために補完
|
|
46
|
+
if (offerByAggregateOffer !== undefined) {
|
|
47
|
+
offerByAggregateOffer = {
|
|
48
|
+
...offerByAggregateOffer,
|
|
49
|
+
additionalProperty: (Array.isArray(offerByAggregateOffer.additionalProperty))
|
|
50
|
+
? offerByAggregateOffer.additionalProperty : [],
|
|
51
|
+
addOn: (Array.isArray(offerByAggregateOffer.addOn))
|
|
52
|
+
? offerByAggregateOffer.addOn : [],
|
|
53
|
+
availableAtOrFrom: (Array.isArray(offerByAggregateOffer.availableAtOrFrom))
|
|
54
|
+
? offerByAggregateOffer.availableAtOrFrom : []
|
|
55
|
+
};
|
|
56
|
+
delete (<any>offerByAggregateOffer).$unset;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (util.isDeepStrictEqual(unitPriceOffer, offerByAggregateOffer)) {
|
|
60
|
+
alreadyMigrated = true;
|
|
61
|
+
} else {
|
|
62
|
+
console.error(unitPriceOffer, offerByAggregateOffer);
|
|
63
|
+
throw new Error('not matched');
|
|
50
64
|
}
|
|
51
65
|
|
|
52
66
|
if (alreadyMigrated) {
|
|
53
67
|
console.log('already exist.', unitPriceOffer.project.id, unitPriceOffer.id, unitPriceOffer.identifier, i);
|
|
54
68
|
} else {
|
|
55
69
|
console.log('updating...', unitPriceOffer.project.id, unitPriceOffer.id, unitPriceOffer.identifier, i);
|
|
56
|
-
await offerRepo.saveSyncTask({
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
});
|
|
70
|
+
// await offerRepo.saveSyncTask({
|
|
71
|
+
// project: { id: unitPriceOffer.project.id },
|
|
72
|
+
// id: { $in: [String(unitPriceOffer.id)] },
|
|
73
|
+
// identifier: { $in: [] },
|
|
74
|
+
// isDeleted: false,
|
|
75
|
+
// typeOf: chevre.factory.offerType.Offer,
|
|
76
|
+
// options: { emitImmediately: false }
|
|
77
|
+
// });
|
|
64
78
|
updateCount += 1;
|
|
65
79
|
console.log('updated.', unitPriceOffer.project.id, unitPriceOffer.id, unitPriceOffer.identifier, i);
|
|
66
80
|
}
|
|
@@ -97,7 +97,9 @@ export declare class MongoRepository {
|
|
|
97
97
|
* 強制的にoffersコレクションを使用する
|
|
98
98
|
*/
|
|
99
99
|
useOffersAsPrimary?: boolean): Promise<factory.unitPriceOffer.IUnitPriceOffer[]>;
|
|
100
|
-
save(params: factory.unitPriceOffer.IUnitPriceOffer
|
|
100
|
+
save(params: factory.unitPriceOffer.IUnitPriceOffer & {
|
|
101
|
+
$unset?: any;
|
|
102
|
+
}): Promise<factory.unitPriceOffer.IUnitPriceOffer>;
|
|
101
103
|
/**
|
|
102
104
|
* sskts専用オファー保管
|
|
103
105
|
*/
|
package/lib/chevre/repo/offer.js
CHANGED
|
@@ -918,10 +918,11 @@ class MongoRepository {
|
|
|
918
918
|
let doc;
|
|
919
919
|
// USE_AGGREGATE_OFFERS_AS_PRIMARY対応(2023-09-05~)
|
|
920
920
|
if (settings_1.USE_AGGREGATE_OFFERS_AS_PRIMARY) {
|
|
921
|
+
const { $unset } = params, paramsWithoutUnset = __rest(params, ["$unset"]);
|
|
921
922
|
let savedUnitPriceOffer;
|
|
922
923
|
if (params.id === '') {
|
|
923
924
|
const id = uniqid();
|
|
924
|
-
savedUnitPriceOffer = Object.assign(Object.assign({},
|
|
925
|
+
savedUnitPriceOffer = Object.assign(Object.assign({}, paramsWithoutUnset), { id });
|
|
925
926
|
const aggregateOffer = {
|
|
926
927
|
typeOf: factory.offerType.AggregateOffer,
|
|
927
928
|
project: params.project,
|
|
@@ -941,7 +942,7 @@ class MongoRepository {
|
|
|
941
942
|
throw new factory.errors.NotFound(factory.offerType.Offer);
|
|
942
943
|
}
|
|
943
944
|
// 上書き禁止属性を除外
|
|
944
|
-
const { id, identifier, project, typeOf } =
|
|
945
|
+
const { id, identifier, project, typeOf } = paramsWithoutUnset, updateFields = __rest(paramsWithoutUnset, ["id", "identifier", "project", "typeOf"]);
|
|
945
946
|
savedUnitPriceOffer = Object.assign(Object.assign({}, updateFields), { id: originalUnitPriceOffer.id, identifier: originalUnitPriceOffer.identifier, project: originalUnitPriceOffer.project, typeOf: originalUnitPriceOffer.typeOf });
|
|
946
947
|
doc = yield this.aggregateOfferModel.findOneAndUpdate({ 'offers.id': params.id }, {
|
|
947
948
|
$set: {
|
package/package.json
CHANGED