@midwayjs/typegoose 2.13.4 → 2.14.6

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,47 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.14.6](https://github.com/midwayjs/midway/compare/v2.14.5...v2.14.6) (2022-02-08)
7
+
8
+ **Note:** Version bump only for package @midwayjs/typegoose
9
+
10
+
11
+
12
+
13
+
14
+ ## [2.14.2](https://github.com/midwayjs/midway/compare/v2.14.1...v2.14.2) (2021-12-28)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * generate middleware typings ([#1442](https://github.com/midwayjs/midway/issues/1442)) ([1b2f99b](https://github.com/midwayjs/midway/commit/1b2f99b0fcfa6d87fa216ac9277d9f1240ef26a2))
20
+
21
+
22
+
23
+
24
+
25
+ # [2.14.0](https://github.com/midwayjs/midway/compare/v2.13.5...v2.14.0) (2021-12-06)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * mongoose init before config load ([#1401](https://github.com/midwayjs/midway/issues/1401)) ([34d2ab8](https://github.com/midwayjs/midway/commit/34d2ab8b5bcfc9bddf52b9a93d6f3b44960ef537))
31
+
32
+
33
+
34
+
35
+
36
+ ## [2.13.5](https://github.com/midwayjs/midway/compare/v2.13.4...v2.13.5) (2021-10-21)
37
+
38
+
39
+ ### Bug Fixes
40
+
41
+ * remove connection key ([#1337](https://github.com/midwayjs/midway/issues/1337)) ([8e7e912](https://github.com/midwayjs/midway/commit/8e7e9124abbd66c27443851d67217ee76daac8fd))
42
+
43
+
44
+
45
+
46
+
6
47
  ## [2.13.4](https://github.com/midwayjs/midway/compare/v2.13.3...v2.13.4) (2021-10-21)
7
48
 
8
49
 
@@ -1,13 +1,11 @@
1
- import * as mongoose from '@midwayjs/mongoose';
2
- import { IMidwayApplication } from '@midwayjs/core';
1
+ import { IMidwayApplication, IMidwayContainer } from '@midwayjs/core';
3
2
  export declare class TypegooseConfiguration {
4
- connectionFactory: mongoose.MongooseConnectionServiceFactory;
5
3
  oldMongooseConfig: any;
6
4
  legacyMode: boolean;
7
5
  app: IMidwayApplication;
8
- modelMap: Map<any, any>;
6
+ modelMap: WeakMap<object, any>;
9
7
  init(): Promise<void>;
10
- onReady(): Promise<void>;
8
+ onReady(container: IMidwayContainer): Promise<void>;
11
9
  onStop(): Promise<void>;
12
10
  }
13
11
  //# sourceMappingURL=configuration.d.ts.map
@@ -18,29 +18,27 @@ const mongo = require("mongoose");
18
18
  let TypegooseConfiguration = class TypegooseConfiguration {
19
19
  constructor() {
20
20
  this.legacyMode = false;
21
- this.modelMap = new Map();
21
+ this.modelMap = new WeakMap();
22
22
  }
23
23
  async init() {
24
24
  this.app
25
25
  .getApplicationContext()
26
26
  .registerDataHandler(interface_1.ENTITY_MODEL_KEY, (key) => {
27
27
  // return getConnection(key.connectionName).getRepository(key.modelKey);
28
- return this.modelMap.get(key.connectionName).get(key.modelKey);
28
+ return this.modelMap.get(key.modelKey);
29
29
  });
30
30
  }
31
- async onReady() {
31
+ async onReady(container) {
32
32
  var _a, _b;
33
+ const connectionFactory = await container.getAsync(mongoose.MongooseConnectionServiceFactory);
33
34
  const Models = (0, decorator_1.listModule)(interface_1.ENTITY_MODEL_KEY);
34
35
  for (const Model of Models) {
35
36
  const metadata = (_a = (0, decorator_1.getClassMetadata)(interface_1.ENTITY_MODEL_KEY, Model)) !== null && _a !== void 0 ? _a : {};
36
37
  const connectionName = (_b = metadata.connectionName) !== null && _b !== void 0 ? _b : 'default';
37
- const conn = this.connectionFactory.get(connectionName);
38
+ const conn = connectionFactory.get(connectionName);
38
39
  if (conn) {
39
40
  const model = (0, typegoose_1.getModelForClass)(Model, { existingConnection: conn });
40
- if (!this.modelMap.has(connectionName)) {
41
- this.modelMap.set(connectionName, new WeakMap());
42
- }
43
- this.modelMap.get(connectionName).set(Model, model);
41
+ this.modelMap.set(Model, model);
44
42
  }
45
43
  else {
46
44
  throw new Error(`connection name ${metadata.connectionName} not found`);
@@ -58,10 +56,6 @@ let TypegooseConfiguration = class TypegooseConfiguration {
58
56
  }
59
57
  }
60
58
  };
61
- __decorate([
62
- (0, decorator_1.Inject)(),
63
- __metadata("design:type", mongoose.MongooseConnectionServiceFactory)
64
- ], TypegooseConfiguration.prototype, "connectionFactory", void 0);
65
59
  __decorate([
66
60
  (0, decorator_1.Config)('mongoose'),
67
61
  __metadata("design:type", Object)
@@ -1,2 +1,2 @@
1
- export declare function InjectEntityModel(modelKey: any, connectionName?: string): (target: any, propertyKey: string) => void;
1
+ export declare function InjectEntityModel(modelKey: any, connectionName?: any): (target: any, propertyKey: string) => void;
2
2
  //# sourceMappingURL=injectEntityModel.d.ts.map
@@ -3,12 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InjectEntityModel = void 0;
4
4
  const decorator_1 = require("@midwayjs/decorator");
5
5
  const interface_1 = require("../interface");
6
- function InjectEntityModel(modelKey, connectionName = 'default') {
6
+ function InjectEntityModel(modelKey, connectionName) {
7
7
  return (target, propertyKey) => {
8
8
  (0, decorator_1.attachClassMetadata)(interface_1.ENTITY_MODEL_KEY, {
9
9
  key: {
10
10
  modelKey,
11
- connectionName,
12
11
  },
13
12
  propertyName: propertyKey,
14
13
  }, target);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/typegoose",
3
- "version": "2.13.4",
3
+ "version": "2.14.6",
4
4
  "description": "Midway Component for typegoose",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -21,14 +21,14 @@
21
21
  },
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
- "@midwayjs/mongoose": "^2.13.4"
24
+ "@midwayjs/mongoose": "^2.14.6"
25
25
  },
26
26
  "devDependencies": {
27
- "@midwayjs/core": "^2.13.4",
28
- "@midwayjs/decorator": "^2.13.2",
29
- "@midwayjs/mock": "^2.13.4",
27
+ "@midwayjs/core": "^2.14.6",
28
+ "@midwayjs/decorator": "^2.14.0",
29
+ "@midwayjs/mock": "^2.14.6",
30
30
  "@typegoose/typegoose": "^9.0.0",
31
- "mongoose": "~6.0.11"
31
+ "mongoose": "^6.1.3"
32
32
  },
33
- "gitHead": "9e61ff6e854b5641201e7d3df8aa19a7d6287f3d"
33
+ "gitHead": "9041633a98444568643bb5a1e8f10bb58e1f1b19"
34
34
  }