@chevre/domain 20.2.0-alpha.41 → 20.2.0-alpha.42

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.
@@ -35,7 +35,7 @@ export declare class MongoRepository {
35
35
  /**
36
36
  * アクション検索
37
37
  */
38
- search<T extends factory.actionType>(params: factory.action.ISearchConditions, projection?: any): Promise<IAction<T>[]>;
38
+ search<T extends factory.actionType>(params: factory.action.ISearchConditions, inclusion: string[], exclusion: string[]): Promise<IAction<T>[]>;
39
39
  /**
40
40
  * アクション開始
41
41
  */
@@ -386,16 +386,28 @@ class MongoRepository {
386
386
  /**
387
387
  * アクション検索
388
388
  */
389
- search(params, projection) {
389
+ search(params, inclusion, exclusion) {
390
390
  return __awaiter(this, void 0, void 0, function* () {
391
391
  const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
392
- const query = this.actionModel.find((conditions.length > 0) ? { $and: conditions } : {}, (projection !== undefined && projection !== null)
393
- ? projection
394
- : {
392
+ let projection = {};
393
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
394
+ inclusion.forEach((field) => {
395
+ projection[field] = 1;
396
+ });
397
+ }
398
+ else {
399
+ projection = {
395
400
  __v: 0,
396
401
  createdAt: 0,
397
402
  updatedAt: 0
398
- });
403
+ };
404
+ if (Array.isArray(exclusion) && exclusion.length > 0) {
405
+ exclusion.forEach((field) => {
406
+ projection[field] = 0;
407
+ });
408
+ }
409
+ }
410
+ const query = this.actionModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
399
411
  if (typeof params.limit === 'number') {
400
412
  const page = (typeof params.page === 'number') ? params.page : 1;
401
413
  query.limit(params.limit)
@@ -507,7 +519,7 @@ class MongoRepository {
507
519
  project: { id: { $eq: params.project.id } },
508
520
  typeOf: { $eq: factory.actionType.PayAction },
509
521
  object: { paymentMethod: { paymentMethodId: { $eq: params.paymentMethodId } } }
510
- });
522
+ }, [], []);
511
523
  return payActions.shift();
512
524
  });
513
525
  }
@@ -181,7 +181,7 @@ function createSellerFlow(measuredFrom, measuredThrough, sellerId) {
181
181
  const actionsOnExpiredTransactions = yield repos.action.search({
182
182
  typeOf: { $eq: factory.actionType.AuthorizeAction },
183
183
  purpose: { id: { $in: expiredTransactionIds } }
184
- });
184
+ }, [], []);
185
185
  debug(actionsOnExpiredTransactions.length, 'actionsOnExpiredTransactions found.');
186
186
  const numbersOfActionsOnExpired = expiredTransactionIds.map((transactionId) => {
187
187
  return actionsOnExpiredTransactions.filter((action) => action.purpose.id === transactionId).length;
package/package.json CHANGED
@@ -120,5 +120,5 @@
120
120
  "postversion": "git push origin --tags",
121
121
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
122
122
  },
123
- "version": "20.2.0-alpha.41"
123
+ "version": "20.2.0-alpha.42"
124
124
  }