@chevre/domain 21.4.0-alpha.34 → 21.4.0-alpha.35

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.
@@ -42,7 +42,7 @@ export declare class MongoRepository {
42
42
  /**
43
43
  * プロジェクト検索
44
44
  */
45
- search(conditions: factory.project.ISearchConditions, projection?: any): Promise<factory.project.IProject[]>;
45
+ search(conditions: factory.project.ISearchConditions, inclusion: string[], exclusion: string[]): Promise<factory.project.IProject[]>;
46
46
  createById(params: factory.project.IProject): Promise<factory.project.IProject>;
47
47
  findByIdAndIUpdate(params: {
48
48
  id: string;
@@ -95,11 +95,33 @@ class MongoRepository {
95
95
  /**
96
96
  * プロジェクト検索
97
97
  */
98
- search(conditions, projection) {
98
+ search(conditions,
99
+ // inclusion対応(2023-07-27~)
100
+ inclusion, exclusion
101
+ // projection?: any
102
+ ) {
99
103
  var _a;
100
104
  return __awaiter(this, void 0, void 0, function* () {
101
105
  const andConditions = MongoRepository.CREATE_MONGO_CONDITIONS(conditions);
102
- const query = this.projectModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection));
106
+ let projection = {};
107
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
108
+ inclusion.forEach((field) => {
109
+ projection[field] = 1;
110
+ });
111
+ }
112
+ else {
113
+ projection = {
114
+ __v: 0,
115
+ createdAt: 0,
116
+ updatedAt: 0
117
+ };
118
+ if (Array.isArray(exclusion) && exclusion.length > 0) {
119
+ exclusion.forEach((field) => {
120
+ projection[field] = 0;
121
+ });
122
+ }
123
+ }
124
+ const query = this.projectModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, projection);
103
125
  if (typeof conditions.limit === 'number' && conditions.limit > 0) {
104
126
  const page = (typeof conditions.page === 'number' && conditions.page > 0) ? conditions.page : 1;
105
127
  query.limit(conditions.limit)
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.4.0-alpha.34"
120
+ "version": "21.4.0-alpha.35"
121
121
  }