@chevre/domain 21.9.0-alpha.13 → 21.9.0-alpha.15
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.
- package/example/src/chevre/searchOfferCatalogItemAvailability.ts +38 -0
- package/example/src/chevre/searchOfferCatalogItems.ts +41 -26
- package/example/src/chevre/searchOffers.ts +16 -4
- package/example/src/chevre/syncCatalogs2aggregateOffers.ts +3 -2
- package/lib/chevre/repo/aggregateOffer.d.ts +0 -96
- package/lib/chevre/repo/aggregateOffer.js +187 -102
- package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +45 -45
- package/lib/chevre/repo/offer.d.ts +16 -0
- package/lib/chevre/repo/offer.js +83 -44
- package/lib/chevre/repo/offerCatalog.d.ts +11 -0
- package/lib/chevre/repo/offerCatalog.js +30 -1
- package/lib/chevre/repo/offerCatalogItem.d.ts +6 -1
- package/lib/chevre/repo/offerCatalogItem.js +46 -23
- package/lib/chevre/repo/task.d.ts +1 -1
- package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +51 -1
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +116 -1
- package/lib/chevre/service/offer/event.d.ts +2 -2
- package/lib/chevre/service/offer/event.js +3 -1
- package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +3 -3
- package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.d.ts +20 -0
- package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +28 -0
- package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +2 -127
- package/lib/chevre/service/task/onResourceUpdated.js +2 -2
- package/package.json +3 -3
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// const PROJECT_ID = process.env.PROJECT_ID;
|
|
7
|
+
mongoose.Model.on('index', (...args) => {
|
|
8
|
+
console.error('******** index event emitted. ********\n', args);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
async function main() {
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
+
|
|
14
|
+
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
15
|
+
const offerRepo = new chevre.repository.Offer(mongoose.connection);
|
|
16
|
+
const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
|
|
17
|
+
const productRepo = new chevre.repository.Product(mongoose.connection);
|
|
18
|
+
|
|
19
|
+
const result = await chevre.service.offer.event.searchOfferCatalogItemAvailability({
|
|
20
|
+
event: {
|
|
21
|
+
id: 'cllkq475u'
|
|
22
|
+
},
|
|
23
|
+
limit: 10,
|
|
24
|
+
page: 1,
|
|
25
|
+
availableAtOrFrom: { id: '3eo6okferrsdpfd9j2ce1iv9k7' }
|
|
26
|
+
})({
|
|
27
|
+
event: eventRepo,
|
|
28
|
+
offer: offerRepo,
|
|
29
|
+
offerCatalog: offerCatalogRepo,
|
|
30
|
+
product: productRepo
|
|
31
|
+
});
|
|
32
|
+
console.log(result);
|
|
33
|
+
console.log(result.length);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
main()
|
|
37
|
+
.then(console.log)
|
|
38
|
+
.catch(console.error);
|
|
@@ -3,7 +3,7 @@ import * as mongoose from 'mongoose';
|
|
|
3
3
|
|
|
4
4
|
import { chevre } from '../../../lib/index';
|
|
5
5
|
|
|
6
|
-
const PROJECT_ID = process.env.PROJECT_ID;
|
|
6
|
+
// const PROJECT_ID = process.env.PROJECT_ID;
|
|
7
7
|
mongoose.Model.on('index', (...args) => {
|
|
8
8
|
console.error('******** index event emitted. ********\n', args);
|
|
9
9
|
});
|
|
@@ -11,31 +11,46 @@ mongoose.Model.on('index', (...args) => {
|
|
|
11
11
|
async function main() {
|
|
12
12
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
14
|
+
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
15
|
+
const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
|
|
16
|
+
const offerCatalogItemRepo = new chevre.repository.OfferCatalogItem(mongoose.connection);
|
|
17
|
+
const productRepo = new chevre.repository.Product(mongoose.connection);
|
|
18
|
+
|
|
19
|
+
const result = await chevre.service.offer.event.searchOfferCatalogItems({
|
|
20
|
+
event: {
|
|
21
|
+
id: 'cllkq475u'
|
|
22
|
+
},
|
|
23
|
+
limit: 10,
|
|
24
|
+
page: 1
|
|
25
|
+
})({
|
|
26
|
+
event: eventRepo,
|
|
27
|
+
offerCatalog: offerCatalogRepo,
|
|
28
|
+
offerCatalogItem: offerCatalogItemRepo,
|
|
29
|
+
product: productRepo
|
|
30
|
+
});
|
|
31
|
+
console.log(result);
|
|
32
|
+
console.log(result.length);
|
|
33
|
+
|
|
34
|
+
// console.log('searching...');
|
|
35
|
+
// const catalogs = await catalogItemRepo.search(
|
|
36
|
+
// {
|
|
37
|
+
// project: { id: { $eq: PROJECT_ID } },
|
|
38
|
+
// sort: { identifier: chevre.factory.sortType.Descending },
|
|
39
|
+
// limit: 2,
|
|
40
|
+
// page: 1,
|
|
41
|
+
// itemListElement: { typeOf: { $eq: 'Offer' } }
|
|
42
|
+
// }
|
|
43
|
+
// );
|
|
44
|
+
// console.log(catalogs[0]?.id, typeof catalogs[0]?.id);
|
|
45
|
+
// console.log(catalogs.length);
|
|
46
|
+
|
|
47
|
+
// const numCatalogs = await catalogItemRepo.count(
|
|
48
|
+
// {
|
|
49
|
+
// project: { id: { $eq: PROJECT_ID } },
|
|
50
|
+
// itemListElement: { typeOf: { $eq: 'Offer' } }
|
|
51
|
+
// }
|
|
52
|
+
// );
|
|
53
|
+
// console.log('numCatalogs:', numCatalogs);
|
|
39
54
|
}
|
|
40
55
|
|
|
41
56
|
main()
|
|
@@ -3,8 +3,20 @@ import * as mongoose from 'mongoose';
|
|
|
3
3
|
|
|
4
4
|
import { chevre } from '../../../lib/index';
|
|
5
5
|
|
|
6
|
+
mongoose.Model.on('index', (...args) => {
|
|
7
|
+
console.error('******** index event emitted. ********\n', args);
|
|
8
|
+
});
|
|
9
|
+
|
|
6
10
|
async function main() {
|
|
7
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex:
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: true });
|
|
12
|
+
|
|
13
|
+
const indexes = await mongoose.connection.db.collection('aggregateOffers')
|
|
14
|
+
.indexes();
|
|
15
|
+
console.log(indexes);
|
|
16
|
+
console.log(indexes.length);
|
|
17
|
+
// await mongoose.connection.db.collection('aggregateOffers')
|
|
18
|
+
// .dropIndexes();
|
|
19
|
+
// console.log('indexes droped');
|
|
8
20
|
|
|
9
21
|
const offerRepo = new chevre.repository.Offer(mongoose.connection);
|
|
10
22
|
|
|
@@ -33,9 +45,9 @@ async function main() {
|
|
|
33
45
|
// ]
|
|
34
46
|
// }
|
|
35
47
|
});
|
|
36
|
-
console.log(offers.map((offer) => {
|
|
37
|
-
|
|
38
|
-
}));
|
|
48
|
+
// console.log(offers.map((offer) => {
|
|
49
|
+
// return `${offer.project.id} ${offer.id} ${offer.identifier} ${offer.name.ja}`;
|
|
50
|
+
// }));
|
|
39
51
|
console.log(offers.length);
|
|
40
52
|
}
|
|
41
53
|
|
|
@@ -11,7 +11,7 @@ mongoose.Model.on('index', (...args) => {
|
|
|
11
11
|
// tslint:disable-next-line:max-func-body-length
|
|
12
12
|
async function main() {
|
|
13
13
|
const now = new Date();
|
|
14
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex:
|
|
14
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
15
15
|
|
|
16
16
|
const offerRepo = new chevre.repository.Offer(mongoose.connection);
|
|
17
17
|
const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
|
|
@@ -20,6 +20,7 @@ async function main() {
|
|
|
20
20
|
const cursor = offerCatalogRepo.getCursor(
|
|
21
21
|
{
|
|
22
22
|
// 'project.id': { $eq: project.id }
|
|
23
|
+
'itemListElement.typeOf': { $exists: true, $eq: chevre.factory.offerType.Offer }
|
|
23
24
|
},
|
|
24
25
|
{
|
|
25
26
|
__v: 0,
|
|
@@ -70,7 +71,7 @@ async function main() {
|
|
|
70
71
|
runsAt: now,
|
|
71
72
|
status: chevre.factory.taskStatus.Ready
|
|
72
73
|
};
|
|
73
|
-
await taskRepo.saveMany([syncTask], { emitImmediately: false });
|
|
74
|
+
// await taskRepo.saveMany([syncTask], { emitImmediately: false });
|
|
74
75
|
updateCount += 1;
|
|
75
76
|
console.log('task saved.', offerCatalog.project.id, offerCatalog.id, offerCatalog.identifier, i);
|
|
76
77
|
}
|
|
@@ -59,111 +59,15 @@ export declare class MongoRepository {
|
|
|
59
59
|
};
|
|
60
60
|
};
|
|
61
61
|
}): Promise<void>;
|
|
62
|
-
pushIncludedInOfferCatalogItem(params: {
|
|
63
|
-
project: {
|
|
64
|
-
id: string;
|
|
65
|
-
};
|
|
66
|
-
id: {
|
|
67
|
-
$in: string[];
|
|
68
|
-
};
|
|
69
|
-
$push: {
|
|
70
|
-
includedInOfferCatalogItem: {
|
|
71
|
-
/**
|
|
72
|
-
* サブカタログID
|
|
73
|
-
*/
|
|
74
|
-
id: {
|
|
75
|
-
$eq: string;
|
|
76
|
-
};
|
|
77
|
-
includedInDataCatalog: {
|
|
78
|
-
/**
|
|
79
|
-
* カタログID
|
|
80
|
-
*/
|
|
81
|
-
id: {
|
|
82
|
-
$eq: string;
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
}): Promise<void>;
|
|
88
62
|
/**
|
|
89
63
|
* サブカタログを含み、かつ、新しいカタログに含まれない集計オファーからサブカタログを除外
|
|
90
64
|
*/
|
|
91
|
-
pullIncludedInOfferCatalogItem(params: {
|
|
92
|
-
project: {
|
|
93
|
-
id: string;
|
|
94
|
-
};
|
|
95
|
-
id?: {
|
|
96
|
-
$nin?: string[];
|
|
97
|
-
};
|
|
98
|
-
$pull: {
|
|
99
|
-
includedInOfferCatalogItem: {
|
|
100
|
-
$elemMatch: {
|
|
101
|
-
/**
|
|
102
|
-
* サブカタログID
|
|
103
|
-
*/
|
|
104
|
-
id: {
|
|
105
|
-
$eq: string;
|
|
106
|
-
};
|
|
107
|
-
includedInDataCatalog: {
|
|
108
|
-
/**
|
|
109
|
-
* カタログID
|
|
110
|
-
*/
|
|
111
|
-
id: {
|
|
112
|
-
$eq: string;
|
|
113
|
-
};
|
|
114
|
-
};
|
|
115
|
-
};
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
}): Promise<void>;
|
|
119
65
|
/**
|
|
120
66
|
* カタログに属するサブカタログを全て除外する
|
|
121
67
|
*/
|
|
122
|
-
pullIncludedInOfferCatalogItemByCatalogId(params: {
|
|
123
|
-
project: {
|
|
124
|
-
id: string;
|
|
125
|
-
};
|
|
126
|
-
$pull: {
|
|
127
|
-
includedInOfferCatalogItem: {
|
|
128
|
-
$elemMatch: {
|
|
129
|
-
/**
|
|
130
|
-
* サブカタログID除外リスト
|
|
131
|
-
*/
|
|
132
|
-
id?: {
|
|
133
|
-
$nin: string[];
|
|
134
|
-
};
|
|
135
|
-
includedInDataCatalog: {
|
|
136
|
-
/**
|
|
137
|
-
* カタログID
|
|
138
|
-
*/
|
|
139
|
-
id: {
|
|
140
|
-
$eq: string;
|
|
141
|
-
};
|
|
142
|
-
};
|
|
143
|
-
};
|
|
144
|
-
};
|
|
145
|
-
};
|
|
146
|
-
}): Promise<void>;
|
|
147
68
|
/**
|
|
148
69
|
* サブカタログに属するサブカタログを全て除外する
|
|
149
70
|
*/
|
|
150
|
-
pullIncludedInOfferCatalogItemByCatalogItemId(params: {
|
|
151
|
-
project: {
|
|
152
|
-
id: string;
|
|
153
|
-
};
|
|
154
|
-
$pull: {
|
|
155
|
-
includedInOfferCatalogItem: {
|
|
156
|
-
$elemMatch: {
|
|
157
|
-
/**
|
|
158
|
-
* サブカタログID
|
|
159
|
-
*/
|
|
160
|
-
id: {
|
|
161
|
-
$eq: string;
|
|
162
|
-
};
|
|
163
|
-
};
|
|
164
|
-
};
|
|
165
|
-
};
|
|
166
|
-
}): Promise<void>;
|
|
167
71
|
deleteById(params: {
|
|
168
72
|
project: {
|
|
169
73
|
id: string;
|
|
@@ -558,117 +558,202 @@ class MongoRepository {
|
|
|
558
558
|
.exec();
|
|
559
559
|
});
|
|
560
560
|
}
|
|
561
|
-
pushIncludedInOfferCatalogItem(params
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
561
|
+
// public async pushIncludedInOfferCatalogItem(params: {
|
|
562
|
+
// project: { id: string };
|
|
563
|
+
// id: { $in: string[] };
|
|
564
|
+
// $push: {
|
|
565
|
+
// includedInOfferCatalogItem: {
|
|
566
|
+
// /**
|
|
567
|
+
// * サブカタログID
|
|
568
|
+
// */
|
|
569
|
+
// id: { $eq: string };
|
|
570
|
+
// includedInDataCatalog: {
|
|
571
|
+
// /**
|
|
572
|
+
// * カタログID
|
|
573
|
+
// */
|
|
574
|
+
// id: { $eq: string };
|
|
575
|
+
// };
|
|
576
|
+
// };
|
|
577
|
+
// };
|
|
578
|
+
// }): Promise<void> {
|
|
579
|
+
// if (!Array.isArray(params.id.$in) || params.id.$in.length === 0) {
|
|
580
|
+
// return;
|
|
581
|
+
// }
|
|
582
|
+
// const newIncludedInOfferCatalogItem: {
|
|
583
|
+
// /**
|
|
584
|
+
// * サブカタログID
|
|
585
|
+
// */
|
|
586
|
+
// id: string;
|
|
587
|
+
// typeOf: 'OfferCatalog';
|
|
588
|
+
// includedInDataCatalog: {
|
|
589
|
+
// /**
|
|
590
|
+
// * カタログID
|
|
591
|
+
// */
|
|
592
|
+
// id: string;
|
|
593
|
+
// typeOf: 'OfferCatalog';
|
|
594
|
+
// };
|
|
595
|
+
// } = {
|
|
596
|
+
// id: params.$push.includedInOfferCatalogItem.id.$eq,
|
|
597
|
+
// typeOf: 'OfferCatalog',
|
|
598
|
+
// includedInDataCatalog: { id: params.$push.includedInOfferCatalogItem.includedInDataCatalog.id.$eq, typeOf: 'OfferCatalog' }
|
|
599
|
+
// };
|
|
600
|
+
// const result = await this.aggregateOfferModel.updateMany(
|
|
601
|
+
// {
|
|
602
|
+
// 'project.id': { $eq: params.project.id },
|
|
603
|
+
// _id: { $in: params.id.$in }
|
|
604
|
+
// },
|
|
605
|
+
// {
|
|
606
|
+
// // newIncludedInOfferCatalogItemsのユニークネスを保証する
|
|
607
|
+
// $addToSet: { 'offers.$[].includedInOfferCatalogItem': newIncludedInOfferCatalogItem }
|
|
608
|
+
// }
|
|
609
|
+
// )
|
|
610
|
+
// .exec();
|
|
611
|
+
// debug('result', result);
|
|
612
|
+
// }
|
|
585
613
|
/**
|
|
586
614
|
* サブカタログを含み、かつ、新しいカタログに含まれない集計オファーからサブカタログを除外
|
|
587
615
|
*/
|
|
588
|
-
pullIncludedInOfferCatalogItem(params
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
616
|
+
// public async pullIncludedInOfferCatalogItem(params: {
|
|
617
|
+
// project: { id: string };
|
|
618
|
+
// id?: { $nin?: string[] };
|
|
619
|
+
// $pull: {
|
|
620
|
+
// includedInOfferCatalogItem: {
|
|
621
|
+
// $elemMatch: {
|
|
622
|
+
// /**
|
|
623
|
+
// * サブカタログID
|
|
624
|
+
// */
|
|
625
|
+
// id: { $eq: string };
|
|
626
|
+
// includedInDataCatalog: {
|
|
627
|
+
// /**
|
|
628
|
+
// * カタログID
|
|
629
|
+
// */
|
|
630
|
+
// id: { $eq: string };
|
|
631
|
+
// };
|
|
632
|
+
// };
|
|
633
|
+
// };
|
|
634
|
+
// };
|
|
635
|
+
// }) {
|
|
636
|
+
// const idNin = params.id?.$nin;
|
|
637
|
+
// await this.aggregateOfferModel.updateMany(
|
|
638
|
+
// {
|
|
639
|
+
// 'project.id': { $eq: params.project.id },
|
|
640
|
+
// 'offers.includedInOfferCatalogItem': {
|
|
641
|
+
// $elemMatch: {
|
|
642
|
+
// id: { $exists: true, $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.id.$eq },
|
|
643
|
+
// 'includedInDataCatalog.id': {
|
|
644
|
+
// $exists: true,
|
|
645
|
+
// $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.includedInDataCatalog.id.$eq
|
|
646
|
+
// }
|
|
647
|
+
// }
|
|
648
|
+
// },
|
|
649
|
+
// ...(Array.isArray(idNin)) ? { _id: { $nin: idNin } } : undefined
|
|
650
|
+
// },
|
|
651
|
+
// {
|
|
652
|
+
// $pull: {
|
|
653
|
+
// 'offers.$[].includedInOfferCatalogItem': {
|
|
654
|
+
// id: { $exists: true, $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.id.$eq },
|
|
655
|
+
// 'includedInDataCatalog.id': {
|
|
656
|
+
// $exists: true,
|
|
657
|
+
// $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.includedInDataCatalog.id.$eq
|
|
658
|
+
// }
|
|
659
|
+
// }
|
|
660
|
+
// }
|
|
661
|
+
// }
|
|
662
|
+
// )
|
|
663
|
+
// .exec();
|
|
664
|
+
// }
|
|
614
665
|
/**
|
|
615
666
|
* カタログに属するサブカタログを全て除外する
|
|
616
667
|
*/
|
|
617
|
-
pullIncludedInOfferCatalogItemByCatalogId(params
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
668
|
+
// public async pullIncludedInOfferCatalogItemByCatalogId(params: {
|
|
669
|
+
// project: { id: string };
|
|
670
|
+
// $pull: {
|
|
671
|
+
// includedInOfferCatalogItem: {
|
|
672
|
+
// $elemMatch: {
|
|
673
|
+
// /**
|
|
674
|
+
// * サブカタログID除外リスト
|
|
675
|
+
// */
|
|
676
|
+
// id?: { $nin: string[] };
|
|
677
|
+
// includedInDataCatalog: {
|
|
678
|
+
// /**
|
|
679
|
+
// * カタログID
|
|
680
|
+
// */
|
|
681
|
+
// id: { $eq: string };
|
|
682
|
+
// };
|
|
683
|
+
// };
|
|
684
|
+
// };
|
|
685
|
+
// };
|
|
686
|
+
// }) {
|
|
687
|
+
// const offerCatalogItemIdNin = params.$pull.includedInOfferCatalogItem.$elemMatch.id?.$nin;
|
|
688
|
+
// await this.aggregateOfferModel.updateMany(
|
|
689
|
+
// {
|
|
690
|
+
// 'project.id': { $eq: params.project.id },
|
|
691
|
+
// 'offers.includedInOfferCatalogItem': {
|
|
692
|
+
// $elemMatch: {
|
|
693
|
+
// 'includedInDataCatalog.id': {
|
|
694
|
+
// $exists: true,
|
|
695
|
+
// $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.includedInDataCatalog.id.$eq
|
|
696
|
+
// }
|
|
697
|
+
// }
|
|
698
|
+
// }
|
|
699
|
+
// },
|
|
700
|
+
// {
|
|
701
|
+
// $pull: {
|
|
702
|
+
// 'offers.$[].includedInOfferCatalogItem': {
|
|
703
|
+
// 'includedInDataCatalog.id': {
|
|
704
|
+
// $exists: true,
|
|
705
|
+
// $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.includedInDataCatalog.id.$eq
|
|
706
|
+
// },
|
|
707
|
+
// ...(Array.isArray(offerCatalogItemIdNin))
|
|
708
|
+
// ? { id: { $nin: offerCatalogItemIdNin } } // // 指定サブカタログを除外する
|
|
709
|
+
// : undefined
|
|
710
|
+
// }
|
|
711
|
+
// }
|
|
712
|
+
// }
|
|
713
|
+
// )
|
|
714
|
+
// .exec();
|
|
715
|
+
// }
|
|
644
716
|
/**
|
|
645
717
|
* サブカタログに属するサブカタログを全て除外する
|
|
646
718
|
*/
|
|
647
|
-
pullIncludedInOfferCatalogItemByCatalogItemId(params
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
}
|
|
719
|
+
// public async pullIncludedInOfferCatalogItemByCatalogItemId(params: {
|
|
720
|
+
// project: { id: string };
|
|
721
|
+
// $pull: {
|
|
722
|
+
// includedInOfferCatalogItem: {
|
|
723
|
+
// $elemMatch: {
|
|
724
|
+
// /**
|
|
725
|
+
// * サブカタログID
|
|
726
|
+
// */
|
|
727
|
+
// id: { $eq: string };
|
|
728
|
+
// };
|
|
729
|
+
// };
|
|
730
|
+
// };
|
|
731
|
+
// }) {
|
|
732
|
+
// await this.aggregateOfferModel.updateMany(
|
|
733
|
+
// {
|
|
734
|
+
// 'project.id': { $eq: params.project.id },
|
|
735
|
+
// 'offers.includedInOfferCatalogItem': {
|
|
736
|
+
// $elemMatch: {
|
|
737
|
+
// id: {
|
|
738
|
+
// $exists: true,
|
|
739
|
+
// $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.id.$eq
|
|
740
|
+
// }
|
|
741
|
+
// }
|
|
742
|
+
// }
|
|
743
|
+
// },
|
|
744
|
+
// {
|
|
745
|
+
// $pull: {
|
|
746
|
+
// 'offers.$[].includedInOfferCatalogItem': {
|
|
747
|
+
// id: {
|
|
748
|
+
// $exists: true,
|
|
749
|
+
// $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.id.$eq
|
|
750
|
+
// }
|
|
751
|
+
// }
|
|
752
|
+
// }
|
|
753
|
+
// }
|
|
754
|
+
// )
|
|
755
|
+
// .exec();
|
|
756
|
+
// }
|
|
672
757
|
deleteById(params) {
|
|
673
758
|
return __awaiter(this, void 0, void 0, function* () {
|
|
674
759
|
yield this.aggregateOfferModel.findOneAndRemove({
|