@midwayjs/typeorm 3.4.0-beta.3 → 3.4.0-beta.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.
@@ -19,7 +19,8 @@ let OrmConfiguration = class OrmConfiguration {
19
19
  async init() {
20
20
  this.decoratorService.registerPropertyHandler(decorator_2.ORM_MODEL_KEY, (propertyName, meta) => {
21
21
  return this.dataSourceManager
22
- .getDataSource(meta.connectionName)
22
+ .getDataSource(meta.connectionName ||
23
+ this.dataSourceManager.getDataSourceNameByModel(meta.modelKey))
23
24
  .getRepository(meta.modelKey);
24
25
  });
25
26
  }
@@ -3,6 +3,7 @@ import { DataSource } from 'typeorm';
3
3
  export declare class TypeORMDataSourceManager extends DataSourceManager<DataSource> {
4
4
  typeormConfig: any;
5
5
  applicationContext: IMidwayContainer;
6
+ baseDir: string;
6
7
  init(): Promise<void>;
7
8
  getName(): string;
8
9
  protected createDataSource(config: any, dataSourceName: string): Promise<DataSource>;
@@ -15,7 +15,7 @@ const core_1 = require("@midwayjs/core");
15
15
  const typeorm_1 = require("typeorm");
16
16
  let TypeORMDataSourceManager = class TypeORMDataSourceManager extends core_1.DataSourceManager {
17
17
  async init() {
18
- await this.initDataSource(this.typeormConfig);
18
+ await this.initDataSource(this.typeormConfig, this.baseDir);
19
19
  }
20
20
  getName() {
21
21
  return 'typeorm';
@@ -42,6 +42,10 @@ __decorate([
42
42
  (0, decorator_1.ApplicationContext)(),
43
43
  __metadata("design:type", Object)
44
44
  ], TypeORMDataSourceManager.prototype, "applicationContext", void 0);
45
+ __decorate([
46
+ (0, decorator_1.Inject)(),
47
+ __metadata("design:type", String)
48
+ ], TypeORMDataSourceManager.prototype, "baseDir", void 0);
45
49
  __decorate([
46
50
  (0, decorator_1.Init)(),
47
51
  __metadata("design:type", Function),
@@ -1,7 +1,8 @@
1
+ import { EntityTarget } from 'typeorm';
1
2
  export declare const ENTITY_MODEL_KEY = "typeorm:entity_model_key";
2
3
  export declare const EVENT_SUBSCRIBER_KEY = "typeorm:event_subscriber_key";
3
4
  export declare const ORM_MODEL_KEY = "typeorm:orm_model_key";
4
- export declare function InjectEntityModel(modelKey: any, connectionName?: string): PropertyDecorator;
5
+ export declare function InjectEntityModel(modelKey: EntityTarget<unknown>, connectionName?: string): PropertyDecorator;
5
6
  /**
6
7
  * EventSubscriber - typeorm
7
8
  * implements EntitySubscriberInterface
package/dist/decorator.js CHANGED
@@ -6,7 +6,7 @@ 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
- function InjectEntityModel(modelKey, connectionName = 'default') {
9
+ function InjectEntityModel(modelKey, connectionName) {
10
10
  return (0, decorator_1.createCustomPropertyDecorator)(exports.ORM_MODEL_KEY, {
11
11
  modelKey,
12
12
  connectionName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/typeorm",
3
- "version": "3.4.0-beta.3",
3
+ "version": "3.4.0-beta.6",
4
4
  "main": "dist/index",
5
5
  "typings": "index.d.ts",
6
6
  "files": [
@@ -9,9 +9,9 @@
9
9
  "index.d.ts"
10
10
  ],
11
11
  "devDependencies": {
12
- "@midwayjs/core": "^3.4.0-beta.3",
13
- "@midwayjs/decorator": "^3.4.0-beta.3",
14
- "@midwayjs/mock": "^3.4.0-beta.3",
12
+ "@midwayjs/core": "^3.4.0-beta.6",
13
+ "@midwayjs/decorator": "^3.4.0-beta.6",
14
+ "@midwayjs/mock": "^3.4.0-beta.6",
15
15
  "sqlite3": "5.0.8",
16
16
  "typeorm": "0.3.7"
17
17
  },
@@ -32,5 +32,5 @@
32
32
  "type": "git",
33
33
  "url": "http://github.com/midwayjs/midway.git"
34
34
  },
35
- "gitHead": "ddbff5c3da5d908953cc691a8e5de4f0197de365"
35
+ "gitHead": "8e187c4593d4832de32b6745af3e195f6b90816c"
36
36
  }