@chevre/domain 22.3.0-alpha.1 → 22.3.0-alpha.2

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.
@@ -6,6 +6,7 @@ import { chevre } from '../../../lib/index';
6
6
  async function main() {
7
7
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
8
8
 
9
+ const accountTitleRepo = await chevre.repository.AccountTitle.createInstance(mongoose.connection);
9
10
  const customerRepo = await chevre.repository.Customer.createInstance(mongoose.connection);
10
11
 
11
12
  let updateResult: any;
@@ -20,6 +21,18 @@ async function main() {
20
21
  }
21
22
  });
22
23
  console.log(updateResult);
24
+
25
+ updateResult = await accountTitleRepo.unsetUnnecessaryFields({
26
+ filter: {
27
+ _id: { $exists: true }
28
+ },
29
+ $unset: {
30
+ createdAt: 1,
31
+ updatedAt: 1,
32
+ __v: 1
33
+ }
34
+ });
35
+ console.log(updateResult);
23
36
  }
24
37
 
25
38
  main()
@@ -41,4 +41,8 @@ export declare class AccountTitleRepo {
41
41
  }, never>, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, factory.accountTitle.IAccountTitle> & Omit<factory.accountTitle.IAccountTitle & {
42
42
  _id: import("mongoose").Types.ObjectId;
43
43
  }, never>>>;
44
+ unsetUnnecessaryFields(params: {
45
+ filter: any;
46
+ $unset: any;
47
+ }): Promise<import("mongodb").UpdateResult>;
44
48
  }
@@ -32,5 +32,11 @@ class AccountTitleRepo {
32
32
  .sort({ codeValue: factory.sortType.Descending })
33
33
  .cursor();
34
34
  }
35
+ unsetUnnecessaryFields(params) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ return this.accountTitleModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
38
+ .exec();
39
+ });
40
+ }
35
41
  }
36
42
  exports.AccountTitleRepo = AccountTitleRepo;
@@ -5,6 +5,6 @@ type IModel = Model<IDocType>;
5
5
  type ISchemaDefinition = SchemaDefinition<IDocType>;
6
6
  type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
7
7
  declare const modelName = "AccountTitle";
8
- declare function createSchema(): ISchema;
9
8
  declare const indexes: [d: IndexDefinition, o: IndexOptions][];
9
+ declare function createSchema(): ISchema;
10
10
  export { createSchema, IModel, indexes, modelName };
@@ -21,6 +21,9 @@ const schemaDefinition = {
21
21
  inDefinedTermSet: mongoose_1.SchemaTypes.Mixed,
22
22
  hasDefinedTerm: mongoose_1.SchemaTypes.Mixed,
23
23
  additionalProperty: mongoose_1.SchemaTypes.Mixed
24
+ // createdAt: SchemaTypes.Mixed,
25
+ // updatedAt: SchemaTypes.Mixed,
26
+ // __v: SchemaTypes.Mixed
24
27
  };
25
28
  const schemaOptions = {
26
29
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -30,10 +33,8 @@ const schemaOptions = {
30
33
  read: settings_1.MONGO_READ_PREFERENCE,
31
34
  writeConcern: writeConcern_1.writeConcern,
32
35
  strictQuery: false,
33
- timestamps: {
34
- createdAt: 'createdAt',
35
- updatedAt: 'updatedAt'
36
- },
36
+ timestamps: false,
37
+ versionKey: false,
37
38
  toJSON: {
38
39
  getters: false,
39
40
  virtuals: false,
@@ -47,26 +48,7 @@ const schemaOptions = {
47
48
  versionKey: false
48
49
  }
49
50
  };
50
- /**
51
- * 勘定科目スキーマ
52
- */
53
- let schema;
54
- function createSchema() {
55
- if (schema === undefined) {
56
- schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
57
- }
58
- return schema;
59
- }
60
- exports.createSchema = createSchema;
61
51
  const indexes = [
62
- [
63
- { createdAt: 1 },
64
- { name: 'searchByCreatedAt' }
65
- ],
66
- [
67
- { updatedAt: 1 },
68
- { name: 'searchByUpdatedAt' }
69
- ],
70
52
  [
71
53
  { codeValue: 1 },
72
54
  { name: 'searchByCodeValue' }
@@ -122,3 +104,34 @@ const indexes = [
122
104
  ]
123
105
  ];
124
106
  exports.indexes = indexes;
107
+ // 'hasCategoryCode.hasCategoryCode.codeValue': null のインデックスは作成されてうまくいかないので保留
108
+ // schema.index(
109
+ // {
110
+ // 'project.id': 1,
111
+ // 'hasCategoryCode.hasCategoryCode.codeValue': 1
112
+ // },
113
+ // {
114
+ // name: 'uniqueHasCategoryCodeHasCategoryCodeCodeValue',
115
+ // unique: true,
116
+ // partialFilterExpression: {
117
+ // 'project.id': { $exists: true },
118
+ // 'hasCategoryCode.hasCategoryCode.codeValue': { $exists: true }
119
+ // }
120
+ // }
121
+ // );
122
+ /**
123
+ * 勘定科目スキーマ
124
+ */
125
+ let schema;
126
+ function createSchema() {
127
+ if (schema === undefined) {
128
+ schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
129
+ if (settings_1.MONGO_AUTO_INDEX) {
130
+ indexes.forEach((indexParams) => {
131
+ schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
132
+ });
133
+ }
134
+ }
135
+ return schema;
136
+ }
137
+ exports.createSchema = createSchema;
package/package.json CHANGED
@@ -110,5 +110,5 @@
110
110
  "postversion": "git push origin --tags",
111
111
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
112
112
  },
113
- "version": "22.3.0-alpha.1"
113
+ "version": "22.3.0-alpha.2"
114
114
  }