@chevre/domain 21.9.0-alpha.8 → 21.9.0

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.
Files changed (32) hide show
  1. package/example/src/chevre/searchAvaialbleAppliesToMovieTicketByOfferCatalogId.ts +4 -1
  2. package/example/src/chevre/searchEventTicketOffers.ts +1 -0
  3. package/example/src/chevre/searchOfferCatalogItemAvailability.ts +38 -0
  4. package/example/src/chevre/searchOfferCatalogItems.ts +41 -26
  5. package/example/src/chevre/searchOffers.ts +16 -4
  6. package/example/src/chevre/searchOffersByCatalog.ts +9 -3
  7. package/example/src/chevre/syncCatalogs2aggregateOffers.ts +23 -21
  8. package/lib/chevre/repo/aggregateOffer.d.ts +19 -3
  9. package/lib/chevre/repo/aggregateOffer.js +227 -27
  10. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +45 -45
  11. package/lib/chevre/repo/offer.d.ts +21 -13
  12. package/lib/chevre/repo/offer.js +145 -58
  13. package/lib/chevre/repo/offerCatalog.d.ts +11 -3
  14. package/lib/chevre/repo/offerCatalog.js +30 -15
  15. package/lib/chevre/repo/offerCatalogItem.d.ts +20 -1
  16. package/lib/chevre/repo/offerCatalogItem.js +67 -23
  17. package/lib/chevre/repo/task.d.ts +1 -1
  18. package/lib/chevre/service/assetTransaction/reserve.js +1 -0
  19. package/lib/chevre/service/offer/event/authorize.js +1 -0
  20. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +53 -7
  21. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +127 -6
  22. package/lib/chevre/service/offer/event.d.ts +2 -2
  23. package/lib/chevre/service/offer/event.js +3 -1
  24. package/lib/chevre/service/offer/product/searchProductOffers.js +4 -3
  25. package/lib/chevre/service/offer/product.js +3 -30
  26. package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +3 -3
  27. package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.d.ts +20 -0
  28. package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +28 -0
  29. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +15 -5
  30. package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +45 -33
  31. package/lib/chevre/service/task/onResourceUpdated.js +2 -2
  32. package/package.json +3 -3
@@ -15,9 +15,11 @@ async function main() {
15
15
  limit: 10,
16
16
  page: 1,
17
17
  subOfferCatalog: {
18
- id: '0001'
18
+ id: '0001',
19
+ isOfferCatalogItem: false
19
20
  },
20
21
  excludeAppliesToMovieTicket: false,
22
+ useIncludeInDataCatalog: true,
21
23
  unacceptedPaymentMethod: []
22
24
  });
23
25
  console.log(result);
@@ -26,6 +28,7 @@ async function main() {
26
28
  result = await chevre.service.offer.event.searchOfferAppliesToMovieTicket({
27
29
  event: { id: 'cllkq475p' },
28
30
  onlyValid: true,
31
+ useIncludeInDataCatalog: true,
29
32
  limit: 100,
30
33
  page: 1
31
34
  // ...(typeof availableAtId === 'string') ? { store: { id: availableAtId } } : undefined
@@ -28,6 +28,7 @@ async function main() {
28
28
  const { ticketOffers } = await chevre.service.offer.event.searchEventTicketOffers({
29
29
  event: { id: 'ale6qiedq' },
30
30
  onlyValid: true,
31
+ priceSpecification: {},
31
32
  validateOfferRateLimit: true,
32
33
  addSortIndex: true,
33
34
  useIncludeInDataCatalog: true,
@@ -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 catalogItemRepo = new chevre.repository.OfferCatalogItem(mongoose.connection);
15
-
16
- console.log('searching...');
17
- const catalogs = await catalogItemRepo.search(
18
- {
19
- project: { id: { $eq: PROJECT_ID } },
20
- sort: { identifier: chevre.factory.sortType.Descending },
21
- limit: 2,
22
- page: 1,
23
- itemListElement: { typeOf: { $eq: 'Offer' } }
24
- // id: { $in: ['xxx'] }
25
- }
26
- );
27
- console.log(catalogs[0]?.id, typeof catalogs[0]?.id);
28
- console.log('catalogs found', catalogs.map((catalog) => `${catalog.id} ${catalog.identifier} ${catalog.numberOfItems} ${catalog.itemListElementTypeOf}`));
29
- console.log(catalogs.length);
30
-
31
- const numCatalogs = await catalogItemRepo.count(
32
- {
33
- project: { id: { $eq: PROJECT_ID } },
34
- itemListElement: { typeOf: { $eq: 'Offer' } }
35
- // id: { $in: ['xxx'] }
36
- }
37
- );
38
- console.log('numCatalogs:', numCatalogs);
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: false });
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
- return `${offer.project.id} ${offer.id} ${offer.identifier} ${offer.name.ja}`;
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
 
@@ -14,11 +14,17 @@ async function main() {
14
14
  page: 1,
15
15
  // ids: ['xx', 'xxx', '1001', '901'],
16
16
  subOfferCatalog: {
17
- id: 'xxx',
18
- isOfferCatalogItem: true
17
+ id: '0001',
18
+ isOfferCatalogItem: false
19
19
  },
20
20
  excludeAppliesToMovieTicket: false,
21
- useIncludeInDataCatalog: false
21
+ useIncludeInDataCatalog: false,
22
+ priceSpecification: {
23
+ // appliesToMovieTicket: {
24
+ // serviceOutput: { typeOf: { $eq: 'SurfRock' } },
25
+ // serviceType: { $exists: true }
26
+ // }
27
+ }
22
28
  });
23
29
  // console.log(offers);
24
30
  console.log(offers.map((offer) => {
@@ -11,15 +11,17 @@ 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: true });
14
+ console.log('now:', now);
15
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
15
16
 
16
17
  const offerRepo = new chevre.repository.Offer(mongoose.connection);
17
18
  const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
18
- const taskRepo = new chevre.repository.Task(mongoose.connection);
19
+ // const taskRepo = new chevre.repository.Task(mongoose.connection);
19
20
 
20
21
  const cursor = offerCatalogRepo.getCursor(
21
22
  {
22
23
  // 'project.id': { $eq: project.id }
24
+ 'itemListElement.typeOf': { $exists: true, $eq: chevre.factory.offerType.Offer }
23
25
  },
24
26
  {
25
27
  __v: 0,
@@ -52,25 +54,25 @@ async function main() {
52
54
  console.log('already synced.', offerCatalog.project.id, offerCatalog.id, offerCatalog.identifier, i);
53
55
  } else {
54
56
  console.log('creating task...', offerCatalog.project.id, offerCatalog.id, offerCatalog.identifier, i);
55
- const syncTaskData: chevre.factory.task.onResourceUpdated.IData4common = {
56
- typeOf: 'OfferCatalog',
57
- id: [String(offerCatalog.id)],
58
- isNew: false,
59
- isDeleted: false,
60
- project: { id: offerCatalog.project.id },
61
- useInform: false
62
- };
63
- const syncTask: chevre.factory.task.IAttributes<chevre.factory.taskName.OnResourceUpdated> = {
64
- data: syncTaskData,
65
- executionResults: [],
66
- name: chevre.factory.taskName.OnResourceUpdated,
67
- numberOfTried: 0,
68
- project: offerCatalog.project,
69
- remainingNumberOfTries: 1,
70
- runsAt: now,
71
- status: chevre.factory.taskStatus.Ready
72
- };
73
- await taskRepo.saveMany([syncTask], { emitImmediately: false });
57
+ // const syncTaskData: chevre.factory.task.onResourceUpdated.IData4common = {
58
+ // typeOf: 'OfferCatalog',
59
+ // id: [String(offerCatalog.id)],
60
+ // isNew: false,
61
+ // isDeleted: false,
62
+ // project: { id: offerCatalog.project.id },
63
+ // useInform: false
64
+ // };
65
+ // const syncTask: chevre.factory.task.IAttributes<chevre.factory.taskName.OnResourceUpdated> = {
66
+ // data: syncTaskData,
67
+ // executionResults: [],
68
+ // name: chevre.factory.taskName.OnResourceUpdated,
69
+ // numberOfTried: 0,
70
+ // project: offerCatalog.project,
71
+ // remainingNumberOfTries: 1,
72
+ // runsAt: now,
73
+ // status: chevre.factory.taskStatus.Ready
74
+ // };
75
+ // await taskRepo.saveMany([syncTask], { emitImmediately: false });
74
76
  updateCount += 1;
75
77
  console.log('task saved.', offerCatalog.project.id, offerCatalog.id, offerCatalog.identifier, i);
76
78
  }
@@ -11,18 +11,19 @@ export type IUnitPriceOfferFromAggregateOffer = factory.unitPriceOffer.IUnitPric
11
11
  id: string;
12
12
  };
13
13
  };
14
+ type ISearchConditions = factory.unitPriceOffer.ISearchConditions;
14
15
  /**
15
16
  * 集計オファーリポジトリ
16
17
  */
17
18
  export declare class MongoRepository {
18
19
  private readonly aggregateOfferModel;
19
20
  constructor(connection: Connection);
20
- static CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params: factory.unitPriceOffer.ISearchConditions): IMatchStage[];
21
+ static CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params: ISearchConditions): IMatchStage[];
21
22
  static CREATE_AGGREGATE_OFFERS_PROJECTION(params: IProjection): {
22
23
  [field: string]: AnyExpression;
23
24
  };
24
- count(params: Omit<factory.unitPriceOffer.ISearchConditions, 'limit' | 'page' | 'sort'>): Promise<number>;
25
- search(params: factory.unitPriceOffer.ISearchConditions, projection?: IProjection): Promise<factory.aggregateOffer.IAggregateOffer[]>;
25
+ count(params: Omit<ISearchConditions, 'limit' | 'page' | 'sort'>): Promise<number>;
26
+ search(params: ISearchConditions, projection?: IProjection): Promise<factory.aggregateOffer.IAggregateOffer[]>;
26
27
  pushIncludedInDataCatalog(params: {
27
28
  project: {
28
29
  id: string;
@@ -58,5 +59,20 @@ export declare class MongoRepository {
58
59
  };
59
60
  };
60
61
  }): Promise<void>;
62
+ /**
63
+ * サブカタログを含み、かつ、新しいカタログに含まれない集計オファーからサブカタログを除外
64
+ */
65
+ /**
66
+ * カタログに属するサブカタログを全て除外する
67
+ */
68
+ /**
69
+ * サブカタログに属するサブカタログを全て除外する
70
+ */
71
+ deleteById(params: {
72
+ project: {
73
+ id: string;
74
+ };
75
+ id: string;
76
+ }): Promise<void>;
61
77
  }
62
78
  export {};
@@ -494,7 +494,7 @@ class MongoRepository {
494
494
  typeOf: 'OfferCatalog'
495
495
  };
496
496
  });
497
- let result = yield this.aggregateOfferModel.updateMany({
497
+ const result = yield this.aggregateOfferModel.updateMany({
498
498
  'project.id': { $eq: params.project.id },
499
499
  _id: { $in: params.id.$in },
500
500
  // includedInDataCatalogのユニークネスを保証する
@@ -511,24 +511,28 @@ class MongoRepository {
511
511
  })
512
512
  .exec();
513
513
  debug('result', result);
514
- // offersにもpush
515
- result = yield this.aggregateOfferModel.updateMany({
516
- 'project.id': { $eq: params.project.id },
517
- _id: { $in: params.id.$in }
518
- }, {
519
- $push: {
520
- 'offers.$[offer].includedInDataCatalog': {
521
- $each: newIncludedInDataCatalogs
522
- }
523
- }
524
- }, {
525
- // includedInDataCatalogのユニークネスを保証する
526
- arrayFilters: [
527
- { 'offer.includedInDataCatalog.id': { $nin: pushIncludedInDataCatalogIds } }
528
- ]
529
- })
530
- .exec();
531
- debug('result', result);
514
+ // offersにもpush(ひとまず廃止)
515
+ // result = await this.aggregateOfferModel.updateMany(
516
+ // {
517
+ // 'project.id': { $eq: params.project.id },
518
+ // _id: { $in: params.id.$in }
519
+ // },
520
+ // {
521
+ // $push: {
522
+ // 'offers.$[offer].includedInDataCatalog': {
523
+ // $each: newIncludedInDataCatalogs
524
+ // }
525
+ // }
526
+ // },
527
+ // {
528
+ // // includedInDataCatalogのユニークネスを保証する
529
+ // arrayFilters: [
530
+ // { 'offer.includedInDataCatalog.id': { $nin: pushIncludedInDataCatalogIds } }
531
+ // ]
532
+ // }
533
+ // )
534
+ // .exec();
535
+ // debug('result', result);
532
536
  });
533
537
  }
534
538
  /**
@@ -547,14 +551,210 @@ class MongoRepository {
547
551
  }
548
552
  })
549
553
  .exec();
550
- // 全offersからもpull
551
- yield this.aggregateOfferModel.updateMany(Object.assign({ 'project.id': { $eq: params.project.id }, 'offers.includedInDataCatalog.id': { $exists: true, $eq: pullingCatalogId } }, (Array.isArray(idNin)) ? { _id: { $nin: idNin } } : undefined), {
552
- $pull: {
553
- 'offers.$[].includedInDataCatalog': {
554
- id: { $eq: pullingCatalogId }
555
- }
556
- }
557
- })
554
+ });
555
+ }
556
+ // public async pushIncludedInOfferCatalogItem(params: {
557
+ // project: { id: string };
558
+ // id: { $in: string[] };
559
+ // $push: {
560
+ // includedInOfferCatalogItem: {
561
+ // /**
562
+ // * サブカタログID
563
+ // */
564
+ // id: { $eq: string };
565
+ // includedInDataCatalog: {
566
+ // /**
567
+ // * カタログID
568
+ // */
569
+ // id: { $eq: string };
570
+ // };
571
+ // };
572
+ // };
573
+ // }): Promise<void> {
574
+ // if (!Array.isArray(params.id.$in) || params.id.$in.length === 0) {
575
+ // return;
576
+ // }
577
+ // const newIncludedInOfferCatalogItem: {
578
+ // /**
579
+ // * サブカタログID
580
+ // */
581
+ // id: string;
582
+ // typeOf: 'OfferCatalog';
583
+ // includedInDataCatalog: {
584
+ // /**
585
+ // * カタログID
586
+ // */
587
+ // id: string;
588
+ // typeOf: 'OfferCatalog';
589
+ // };
590
+ // } = {
591
+ // id: params.$push.includedInOfferCatalogItem.id.$eq,
592
+ // typeOf: 'OfferCatalog',
593
+ // includedInDataCatalog: { id: params.$push.includedInOfferCatalogItem.includedInDataCatalog.id.$eq, typeOf: 'OfferCatalog' }
594
+ // };
595
+ // const result = await this.aggregateOfferModel.updateMany(
596
+ // {
597
+ // 'project.id': { $eq: params.project.id },
598
+ // _id: { $in: params.id.$in }
599
+ // },
600
+ // {
601
+ // // newIncludedInOfferCatalogItemsのユニークネスを保証する
602
+ // $addToSet: { 'offers.$[].includedInOfferCatalogItem': newIncludedInOfferCatalogItem }
603
+ // }
604
+ // )
605
+ // .exec();
606
+ // debug('result', result);
607
+ // }
608
+ /**
609
+ * サブカタログを含み、かつ、新しいカタログに含まれない集計オファーからサブカタログを除外
610
+ */
611
+ // public async pullIncludedInOfferCatalogItem(params: {
612
+ // project: { id: string };
613
+ // id?: { $nin?: string[] };
614
+ // $pull: {
615
+ // includedInOfferCatalogItem: {
616
+ // $elemMatch: {
617
+ // /**
618
+ // * サブカタログID
619
+ // */
620
+ // id: { $eq: string };
621
+ // includedInDataCatalog: {
622
+ // /**
623
+ // * カタログID
624
+ // */
625
+ // id: { $eq: string };
626
+ // };
627
+ // };
628
+ // };
629
+ // };
630
+ // }) {
631
+ // const idNin = params.id?.$nin;
632
+ // await this.aggregateOfferModel.updateMany(
633
+ // {
634
+ // 'project.id': { $eq: params.project.id },
635
+ // 'offers.includedInOfferCatalogItem': {
636
+ // $elemMatch: {
637
+ // id: { $exists: true, $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.id.$eq },
638
+ // 'includedInDataCatalog.id': {
639
+ // $exists: true,
640
+ // $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.includedInDataCatalog.id.$eq
641
+ // }
642
+ // }
643
+ // },
644
+ // ...(Array.isArray(idNin)) ? { _id: { $nin: idNin } } : undefined
645
+ // },
646
+ // {
647
+ // $pull: {
648
+ // 'offers.$[].includedInOfferCatalogItem': {
649
+ // id: { $exists: true, $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.id.$eq },
650
+ // 'includedInDataCatalog.id': {
651
+ // $exists: true,
652
+ // $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.includedInDataCatalog.id.$eq
653
+ // }
654
+ // }
655
+ // }
656
+ // }
657
+ // )
658
+ // .exec();
659
+ // }
660
+ /**
661
+ * カタログに属するサブカタログを全て除外する
662
+ */
663
+ // public async pullIncludedInOfferCatalogItemByCatalogId(params: {
664
+ // project: { id: string };
665
+ // $pull: {
666
+ // includedInOfferCatalogItem: {
667
+ // $elemMatch: {
668
+ // /**
669
+ // * サブカタログID除外リスト
670
+ // */
671
+ // id?: { $nin: string[] };
672
+ // includedInDataCatalog: {
673
+ // /**
674
+ // * カタログID
675
+ // */
676
+ // id: { $eq: string };
677
+ // };
678
+ // };
679
+ // };
680
+ // };
681
+ // }) {
682
+ // const offerCatalogItemIdNin = params.$pull.includedInOfferCatalogItem.$elemMatch.id?.$nin;
683
+ // await this.aggregateOfferModel.updateMany(
684
+ // {
685
+ // 'project.id': { $eq: params.project.id },
686
+ // 'offers.includedInOfferCatalogItem': {
687
+ // $elemMatch: {
688
+ // 'includedInDataCatalog.id': {
689
+ // $exists: true,
690
+ // $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.includedInDataCatalog.id.$eq
691
+ // }
692
+ // }
693
+ // }
694
+ // },
695
+ // {
696
+ // $pull: {
697
+ // 'offers.$[].includedInOfferCatalogItem': {
698
+ // 'includedInDataCatalog.id': {
699
+ // $exists: true,
700
+ // $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.includedInDataCatalog.id.$eq
701
+ // },
702
+ // ...(Array.isArray(offerCatalogItemIdNin))
703
+ // ? { id: { $nin: offerCatalogItemIdNin } } // // 指定サブカタログを除外する
704
+ // : undefined
705
+ // }
706
+ // }
707
+ // }
708
+ // )
709
+ // .exec();
710
+ // }
711
+ /**
712
+ * サブカタログに属するサブカタログを全て除外する
713
+ */
714
+ // public async pullIncludedInOfferCatalogItemByCatalogItemId(params: {
715
+ // project: { id: string };
716
+ // $pull: {
717
+ // includedInOfferCatalogItem: {
718
+ // $elemMatch: {
719
+ // /**
720
+ // * サブカタログID
721
+ // */
722
+ // id: { $eq: string };
723
+ // };
724
+ // };
725
+ // };
726
+ // }) {
727
+ // await this.aggregateOfferModel.updateMany(
728
+ // {
729
+ // 'project.id': { $eq: params.project.id },
730
+ // 'offers.includedInOfferCatalogItem': {
731
+ // $elemMatch: {
732
+ // id: {
733
+ // $exists: true,
734
+ // $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.id.$eq
735
+ // }
736
+ // }
737
+ // }
738
+ // },
739
+ // {
740
+ // $pull: {
741
+ // 'offers.$[].includedInOfferCatalogItem': {
742
+ // id: {
743
+ // $exists: true,
744
+ // $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.id.$eq
745
+ // }
746
+ // }
747
+ // }
748
+ // }
749
+ // )
750
+ // .exec();
751
+ // }
752
+ deleteById(params) {
753
+ return __awaiter(this, void 0, void 0, function* () {
754
+ yield this.aggregateOfferModel.findOneAndRemove({
755
+ _id: { $eq: params.id },
756
+ 'project.id': { $eq: params.project.id }
757
+ }, { projection: { _id: 1 } })
558
758
  .exec();
559
759
  });
560
760
  }