@chevre/domain 21.8.0-alpha.39 → 21.8.0-alpha.40

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.
@@ -5,21 +5,27 @@ import * as mongoose from 'mongoose';
5
5
  import { chevre } from '../../../lib/index';
6
6
 
7
7
  async function main() {
8
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
8
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
9
9
 
10
10
  const offerRepo = new chevre.repository.Offer(mongoose.connection);
11
11
 
12
12
  const { offers } = await offerRepo.findOffersByOfferCatalogId({
13
- ids: ['al96nqj7z', 'xxx', '1001'],
13
+ limit: 100,
14
+ page: 1,
15
+ // ids: ['aldzf0vrk', 'xxx', '1001'],
14
16
  // ids: ['xx', 'xxx'],
15
17
  offerCatalog: {
16
- id: '0001'
18
+ id: 'bllroybre'
17
19
  // id: 'xxx'
18
20
  },
19
21
  excludeAppliesToMovieTicket: false
20
22
  });
21
- console.log(offers.map((o) => o.id));
23
+ // console.log(offers);
24
+ console.log(offers.map((offer) => {
25
+ return `${offer.project?.id} ${offer.identifier} ${offer.priceSpecification?.price} ${offer.name?.ja} ${offer.id}`;
26
+ }));
22
27
  console.log(offers.length);
28
+ console.log('USE_AGGREGATE_OFFERS_AS_PRIMARY:', process.env.USE_AGGREGATE_OFFERS_AS_PRIMARY);
23
29
  }
24
30
 
25
31
  main()
@@ -830,7 +830,8 @@ class MongoRepository {
830
830
  }
831
831
  : undefined)
832
832
  }, onlyValid: params.onlyValid === true }), (typeof params.limit === 'number' && typeof params.page === 'number')
833
- ? { sort: { _id: factory.sortType.Ascending } }
833
+ // 明示的なソート指定を調整(決して重複しない属性が相応)(2023-09-07~)
834
+ ? { sort: { identifier: factory.sortType.Ascending } }
834
835
  : undefined), (typeof params.limit === 'number') ? { limit: params.limit } : undefined), (typeof params.page === 'number') ? { page: params.page } : undefined);
835
836
  // USE_AGGREGATE_OFFERS_AS_PRIMARY_ON_SEARCH_BY_CATALOG対応(2023-09-06~)
836
837
  offers = yield this.search(searchOffersConditions, params.projection, settings_1.USE_AGGREGATE_OFFERS_AS_PRIMARY_ON_SEARCH_BY_CATALOG);
@@ -926,11 +927,13 @@ class MongoRepository {
926
927
  query.limit(params.limit)
927
928
  .skip(params.limit * (page - 1));
928
929
  }
929
- // tslint:disable-next-line:no-single-line-block-comment
930
- /* istanbul ignore else */
931
- if (typeof ((_a = params.sort) === null || _a === void 0 ? void 0 : _a['priceSpecification.price']) === 'number') {
932
- query.sort(Object.assign({ 'priceSpecification.price': params.sort['priceSpecification.price'] }, (typeof ((_b = params.sort) === null || _b === void 0 ? void 0 : _b.identifier) === 'number')
933
- ? { identifier: params.sort.identifier }
930
+ const sortByPrice = (_a = params.sort) === null || _a === void 0 ? void 0 : _a['priceSpecification.price'];
931
+ const sortByIdentifier = (_b = params.sort) === null || _b === void 0 ? void 0 : _b.identifier;
932
+ if (typeof sortByPrice === 'number' || typeof sortByIdentifier === 'number') {
933
+ query.sort(Object.assign(Object.assign({}, (typeof sortByPrice === 'number')
934
+ ? { 'priceSpecification.price': sortByPrice }
935
+ : undefined), (typeof sortByIdentifier === 'number')
936
+ ? { identifier: sortByIdentifier }
934
937
  : undefined));
935
938
  }
936
939
  return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
@@ -1479,6 +1482,8 @@ class MongoRepository {
1479
1482
  return __awaiter(this, void 0, void 0, function* () {
1480
1483
  const matchStages = MongoRepository.CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params);
1481
1484
  const projectStage = MongoRepository.CREATE_AGGREGATE_OFFERS_PROJECTION(Object.assign({}, projection));
1485
+ const sortByPrice = (_a = params.sort) === null || _a === void 0 ? void 0 : _a['priceSpecification.price'];
1486
+ const sortByIdentifier = (_b = params.sort) === null || _b === void 0 ? void 0 : _b.identifier;
1482
1487
  const aggregate = this.aggregateOfferModel.aggregate([
1483
1488
  {
1484
1489
  $unwind: {
@@ -1487,11 +1492,13 @@ class MongoRepository {
1487
1492
  }
1488
1493
  },
1489
1494
  ...matchStages,
1490
- ...(typeof ((_a = params.sort) === null || _a === void 0 ? void 0 : _a['priceSpecification.price']) === 'number')
1495
+ ...(typeof sortByPrice === 'number' || typeof sortByIdentifier === 'number')
1491
1496
  ? [
1492
1497
  {
1493
- $sort: Object.assign({ 'offers.priceSpecification.price': params.sort['priceSpecification.price'] }, (typeof ((_b = params.sort) === null || _b === void 0 ? void 0 : _b.identifier) === 'number')
1494
- ? { 'offers.identifier': params.sort.identifier }
1498
+ $sort: Object.assign(Object.assign({}, (typeof sortByPrice === 'number')
1499
+ ? { 'offers.priceSpecification.price': sortByPrice }
1500
+ : undefined), (typeof sortByIdentifier === 'number')
1501
+ ? { 'offers.identifier': sortByIdentifier }
1495
1502
  : undefined)
1496
1503
  }
1497
1504
  ]
package/package.json CHANGED
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.8.0-alpha.39"
120
+ "version": "21.8.0-alpha.40"
121
121
  }