@midwayjs/typegoose 3.20.4 → 4.0.0-beta.1
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/dist/configuration.js
CHANGED
|
@@ -26,7 +26,6 @@ let TypegooseConfiguration = class TypegooseConfiguration {
|
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
async onReady(container) {
|
|
29
|
-
var _a, _b;
|
|
30
29
|
const connectionFactory = await container.getAsync(mongoose.MongooseDataSourceManager);
|
|
31
30
|
for (const dataSourceName of connectionFactory.getDataSourceNames()) {
|
|
32
31
|
const conn = connectionFactory.getDataSource(dataSourceName);
|
|
@@ -37,11 +36,11 @@ let TypegooseConfiguration = class TypegooseConfiguration {
|
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
|
-
const Models =
|
|
39
|
+
const Models = core_1.DecoratorManager.listModule(interface_1.ENTITY_MODEL_KEY);
|
|
41
40
|
// 兼容老代码
|
|
42
41
|
for (const Model of Models) {
|
|
43
|
-
const metadata =
|
|
44
|
-
const connectionName =
|
|
42
|
+
const metadata = core_1.MetadataManager.getOwnMetadata(interface_1.ENTITY_MODEL_KEY, Model) ?? {};
|
|
43
|
+
const connectionName = metadata.connectionName ?? 'default';
|
|
45
44
|
const conn = connectionFactory.getDataSource(connectionName);
|
|
46
45
|
if (conn) {
|
|
47
46
|
const model = (0, typegoose_1.getModelForClass)(Model, { existingConnection: conn });
|
|
@@ -63,12 +62,13 @@ let TypegooseConfiguration = class TypegooseConfiguration {
|
|
|
63
62
|
}
|
|
64
63
|
}
|
|
65
64
|
};
|
|
65
|
+
exports.TypegooseConfiguration = TypegooseConfiguration;
|
|
66
66
|
__decorate([
|
|
67
67
|
(0, core_1.Config)('mongoose'),
|
|
68
68
|
__metadata("design:type", Object)
|
|
69
69
|
], TypegooseConfiguration.prototype, "oldMongooseConfig", void 0);
|
|
70
70
|
__decorate([
|
|
71
|
-
(0, core_1.
|
|
71
|
+
(0, core_1.MainApp)(),
|
|
72
72
|
__metadata("design:type", Object)
|
|
73
73
|
], TypegooseConfiguration.prototype, "app", void 0);
|
|
74
74
|
__decorate([
|
|
@@ -81,11 +81,10 @@ __decorate([
|
|
|
81
81
|
__metadata("design:paramtypes", []),
|
|
82
82
|
__metadata("design:returntype", Promise)
|
|
83
83
|
], TypegooseConfiguration.prototype, "init", null);
|
|
84
|
-
TypegooseConfiguration = __decorate([
|
|
84
|
+
exports.TypegooseConfiguration = TypegooseConfiguration = __decorate([
|
|
85
85
|
(0, core_1.Configuration)({
|
|
86
86
|
namespace: 'typegoose',
|
|
87
87
|
imports: [mongoose],
|
|
88
88
|
})
|
|
89
89
|
], TypegooseConfiguration);
|
|
90
|
-
exports.TypegooseConfiguration = TypegooseConfiguration;
|
|
91
90
|
//# sourceMappingURL=configuration.js.map
|
|
@@ -5,8 +5,8 @@ const core_1 = require("@midwayjs/core");
|
|
|
5
5
|
const interface_1 = require("../interface");
|
|
6
6
|
function EntityModel(options) {
|
|
7
7
|
return (target) => {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
core_1.DecoratorManager.saveModule(interface_1.ENTITY_MODEL_KEY, target);
|
|
9
|
+
core_1.MetadataManager.defineMetadata(interface_1.ENTITY_MODEL_KEY, options, target);
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
exports.EntityModel = EntityModel;
|
|
@@ -4,7 +4,7 @@ exports.InjectEntityModel = void 0;
|
|
|
4
4
|
const core_1 = require("@midwayjs/core");
|
|
5
5
|
const interface_1 = require("../interface");
|
|
6
6
|
function InjectEntityModel(modelKey) {
|
|
7
|
-
return
|
|
7
|
+
return core_1.DecoratorManager.createCustomPropertyDecorator(interface_1.ENTITY_MODEL_KEY, {
|
|
8
8
|
modelKey,
|
|
9
9
|
});
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/typegoose",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-beta.1",
|
|
4
4
|
"description": "Midway Component for typegoose",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc",
|
|
9
|
-
"test": "node
|
|
10
|
-
"cov": "node
|
|
9
|
+
"test": "node -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand",
|
|
10
|
+
"cov": "node -r ts-node/register ../../node_modules/jest/bin/jest.js --runInBand --coverage --forceExit",
|
|
11
11
|
"ci": "npm run test"
|
|
12
12
|
},
|
|
13
13
|
"keywords": [],
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
},
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@midwayjs/mongoose": "^
|
|
25
|
+
"@midwayjs/mongoose": "^4.0.0-beta.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@midwayjs/core": "^
|
|
29
|
-
"@midwayjs/mock": "^
|
|
28
|
+
"@midwayjs/core": "^4.0.0-beta.1",
|
|
29
|
+
"@midwayjs/mock": "^4.0.0-beta.1",
|
|
30
30
|
"@typegoose/typegoose": "12.10.1",
|
|
31
31
|
"mongoose": "8.9.5"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "832961ec3aff123c033197d8c00cb2bc9bad7ff8"
|
|
34
34
|
}
|