@midwayjs/typeorm 3.7.1 → 3.8.0
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 +4 -0
- package/dist/decorator.d.ts +2 -0
- package/dist/decorator.js +8 -1
- package/package.json +5 -5
package/dist/configuration.js
CHANGED
|
@@ -23,6 +23,10 @@ let OrmConfiguration = class OrmConfiguration {
|
|
|
23
23
|
this.dataSourceManager.getDataSourceNameByModel(meta.modelKey))
|
|
24
24
|
.getRepository(meta.modelKey);
|
|
25
25
|
});
|
|
26
|
+
this.decoratorService.registerPropertyHandler(decorator_1.ORM_DATA_SOURCE_KEY, (propertyName, meta) => {
|
|
27
|
+
return this.dataSourceManager.getDataSource(meta.dataSourceName ||
|
|
28
|
+
this.dataSourceManager.getDefaultDataSourceName());
|
|
29
|
+
});
|
|
26
30
|
}
|
|
27
31
|
async onReady(container) {
|
|
28
32
|
(0, typeorm_1.useContainer)(container);
|
package/dist/decorator.d.ts
CHANGED
|
@@ -2,10 +2,12 @@ import { EntityTarget } from 'typeorm';
|
|
|
2
2
|
export declare const ENTITY_MODEL_KEY = "typeorm:entity_model_key";
|
|
3
3
|
export declare const EVENT_SUBSCRIBER_KEY = "typeorm:event_subscriber_key";
|
|
4
4
|
export declare const ORM_MODEL_KEY = "typeorm:orm_model_key";
|
|
5
|
+
export declare const ORM_DATA_SOURCE_KEY = "typeorm:data_source_key";
|
|
5
6
|
export declare function InjectEntityModel(modelKey: EntityTarget<unknown>, connectionName?: string): PropertyDecorator;
|
|
6
7
|
/**
|
|
7
8
|
* EventSubscriber - typeorm
|
|
8
9
|
* implements EntitySubscriberInterface
|
|
9
10
|
*/
|
|
10
11
|
export declare function EventSubscriberModel(): ClassDecorator;
|
|
12
|
+
export declare function InjectDataSource(dataSourceName?: string): PropertyDecorator;
|
|
11
13
|
//# sourceMappingURL=decorator.d.ts.map
|
package/dist/decorator.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EventSubscriberModel = exports.InjectEntityModel = exports.ORM_MODEL_KEY = exports.EVENT_SUBSCRIBER_KEY = exports.ENTITY_MODEL_KEY = void 0;
|
|
3
|
+
exports.InjectDataSource = exports.EventSubscriberModel = exports.InjectEntityModel = exports.ORM_DATA_SOURCE_KEY = exports.ORM_MODEL_KEY = exports.EVENT_SUBSCRIBER_KEY = exports.ENTITY_MODEL_KEY = void 0;
|
|
4
4
|
const core_1 = require("@midwayjs/core");
|
|
5
5
|
const typeorm_1 = require("typeorm");
|
|
6
6
|
exports.ENTITY_MODEL_KEY = 'typeorm:entity_model_key';
|
|
7
7
|
exports.EVENT_SUBSCRIBER_KEY = 'typeorm:event_subscriber_key';
|
|
8
8
|
exports.ORM_MODEL_KEY = 'typeorm:orm_model_key';
|
|
9
|
+
exports.ORM_DATA_SOURCE_KEY = 'typeorm:data_source_key';
|
|
9
10
|
function InjectEntityModel(modelKey, connectionName) {
|
|
10
11
|
return (0, core_1.createCustomPropertyDecorator)(exports.ORM_MODEL_KEY, {
|
|
11
12
|
modelKey,
|
|
@@ -25,4 +26,10 @@ function EventSubscriberModel() {
|
|
|
25
26
|
};
|
|
26
27
|
}
|
|
27
28
|
exports.EventSubscriberModel = EventSubscriberModel;
|
|
29
|
+
function InjectDataSource(dataSourceName) {
|
|
30
|
+
return (0, core_1.createCustomPropertyDecorator)(exports.ORM_DATA_SOURCE_KEY, {
|
|
31
|
+
dataSourceName,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
exports.InjectDataSource = InjectDataSource;
|
|
28
35
|
//# sourceMappingURL=decorator.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/typeorm",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"main": "dist/index",
|
|
5
5
|
"typings": "index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"index.d.ts"
|
|
10
10
|
],
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@midwayjs/core": "^3.
|
|
13
|
-
"@midwayjs/mock": "^3.
|
|
12
|
+
"@midwayjs/core": "^3.8.0",
|
|
13
|
+
"@midwayjs/mock": "^3.8.0",
|
|
14
14
|
"sqlite3": "5.1.2",
|
|
15
15
|
"typeorm": "0.3.10"
|
|
16
16
|
},
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"repository": {
|
|
31
31
|
"type": "git",
|
|
32
|
-
"url": "
|
|
32
|
+
"url": "https://github.com/midwayjs/midway.git"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "5c640c7182923587139f9f9c0aecf50585798e1e"
|
|
35
35
|
}
|