@midwayjs/typeorm 3.11.5 → 3.11.8
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 +19 -5
- package/package.json +5 -5
package/dist/configuration.js
CHANGED
|
@@ -16,12 +16,26 @@ const dataSourceManager_1 = require("./dataSourceManager");
|
|
|
16
16
|
const typeorm_1 = require("typeorm");
|
|
17
17
|
let OrmConfiguration = class OrmConfiguration {
|
|
18
18
|
async init() {
|
|
19
|
-
this.decoratorService.registerPropertyHandler(decorator_1.ORM_MODEL_KEY, (propertyName, meta) => {
|
|
20
|
-
|
|
21
|
-
.getDataSource(meta.connectionName ||
|
|
19
|
+
this.decoratorService.registerPropertyHandler(decorator_1.ORM_MODEL_KEY, (propertyName, meta, instance) => {
|
|
20
|
+
const dataSource = this.dataSourceManager.getDataSource(meta.connectionName ||
|
|
22
21
|
this.dataSourceManager.getDataSourceNameByModel(meta.modelKey) ||
|
|
23
|
-
this.dataSourceManager.getDefaultDataSourceName())
|
|
24
|
-
|
|
22
|
+
this.dataSourceManager.getDefaultDataSourceName());
|
|
23
|
+
if (!dataSource) {
|
|
24
|
+
throw new core_1.MidwayCommonError(`DataSource ${meta.connectionName} not found with current model ${meta.modelKey}, please check it.`);
|
|
25
|
+
}
|
|
26
|
+
const type = (0, core_1.getPropertyType)(instance, propertyName);
|
|
27
|
+
if (type.originDesign === typeorm_1.Repository) {
|
|
28
|
+
return dataSource.getRepository(meta.modelKey);
|
|
29
|
+
}
|
|
30
|
+
else if (type.originDesign === typeorm_1.TreeRepository) {
|
|
31
|
+
return dataSource.getTreeRepository(meta.modelKey);
|
|
32
|
+
}
|
|
33
|
+
else if (type.originDesign === typeorm_1.MongoRepository) {
|
|
34
|
+
return dataSource.getMongoRepository(meta.modelKey);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
return dataSource.getRepository(meta.modelKey);
|
|
38
|
+
}
|
|
25
39
|
});
|
|
26
40
|
this.decoratorService.registerPropertyHandler(decorator_1.ORM_DATA_SOURCE_KEY, (propertyName, meta) => {
|
|
27
41
|
return this.dataSourceManager.getDataSource(meta.dataSourceName ||
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/typeorm",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.8",
|
|
4
4
|
"main": "dist/index",
|
|
5
5
|
"typings": "index.d.ts",
|
|
6
6
|
"bin": {
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"index.d.ts"
|
|
14
14
|
],
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@midwayjs/core": "^3.11.
|
|
17
|
-
"@midwayjs/mock": "^3.11.
|
|
16
|
+
"@midwayjs/core": "^3.11.6",
|
|
17
|
+
"@midwayjs/mock": "^3.11.6",
|
|
18
18
|
"sqlite3": "5.1.6",
|
|
19
|
-
"typeorm": "0.3.
|
|
19
|
+
"typeorm": "0.3.16"
|
|
20
20
|
},
|
|
21
21
|
"author": {
|
|
22
22
|
"name": "czy88840616",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"type": "git",
|
|
36
36
|
"url": "https://github.com/midwayjs/midway.git"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "65e2ca5c92c065c7e73565880562823e00f8e4f4"
|
|
39
39
|
}
|