@midwayjs/sequelize 3.4.0-beta.2 → 3.4.0-beta.5

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.
@@ -18,7 +18,8 @@ let SequelizeConfiguration = class SequelizeConfiguration {
18
18
  async init() {
19
19
  this.decoratorService.registerPropertyHandler(decorator_2.ENTITY_MODEL_KEY, (propertyName, meta) => {
20
20
  return this.dataSourceManager
21
- .getDataSource(meta.connectionName)
21
+ .getDataSource(meta.connectionName ||
22
+ this.dataSourceManager.getDataSourceNameByModel(meta.modelKey))
22
23
  .getRepository(meta.modelKey);
23
24
  });
24
25
  }
@@ -3,6 +3,7 @@ import { Sequelize } from 'sequelize-typescript';
3
3
  export declare class SequelizeDataSourceManager extends DataSourceManager<Sequelize> {
4
4
  sequelizeConfig: any;
5
5
  coreLogger: ILogger;
6
+ baseDir: string;
6
7
  init(): Promise<void>;
7
8
  getName(): string;
8
9
  protected createDataSource(config: any, dataSourceName: string): Promise<Sequelize>;
@@ -23,7 +23,7 @@ let SequelizeDataSourceManager = class SequelizeDataSourceManager extends core_1
23
23
  default: this.sequelizeConfig.options,
24
24
  };
25
25
  }
26
- await this.initDataSource(this.sequelizeConfig);
26
+ await this.initDataSource(this.sequelizeConfig, this.baseDir);
27
27
  }
28
28
  getName() {
29
29
  return 'sequelize';
@@ -69,6 +69,10 @@ __decorate([
69
69
  (0, decorator_1.Logger)('coreLogger'),
70
70
  __metadata("design:type", Object)
71
71
  ], SequelizeDataSourceManager.prototype, "coreLogger", void 0);
72
+ __decorate([
73
+ (0, decorator_1.Inject)(),
74
+ __metadata("design:type", String)
75
+ ], SequelizeDataSourceManager.prototype, "baseDir", void 0);
72
76
  __decorate([
73
77
  (0, decorator_1.Init)(),
74
78
  __metadata("design:type", Function),
@@ -7,5 +7,7 @@ import { Model, TableOptions } from 'sequelize-typescript';
7
7
  export declare function BaseTable<M extends Model = Model>(options: TableOptions<M>): any;
8
8
  export declare function BaseTable(target: any): void;
9
9
  export declare const ENTITY_MODEL_KEY = "sequelize:entity_model_key";
10
- export declare function InjectRepository(modelKey: any, connectionName?: string): PropertyDecorator;
10
+ export declare function InjectRepository(modelKey: {
11
+ new (): Model<any, any>;
12
+ }, connectionName?: string): PropertyDecorator;
11
13
  //# sourceMappingURL=decorator.d.ts.map
package/dist/decorator.js CHANGED
@@ -23,7 +23,7 @@ function annotate(target, options = {}) {
23
23
  (0, sequelize_typescript_1.addOptions)(target.prototype, options);
24
24
  }
25
25
  exports.ENTITY_MODEL_KEY = 'sequelize:entity_model_key';
26
- function InjectRepository(modelKey, connectionName = 'default') {
26
+ function InjectRepository(modelKey, connectionName) {
27
27
  return (0, decorator_1.createCustomPropertyDecorator)(exports.ENTITY_MODEL_KEY, {
28
28
  modelKey,
29
29
  connectionName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/sequelize",
3
- "version": "3.4.0-beta.2",
3
+ "version": "3.4.0-beta.5",
4
4
  "main": "dist/index",
5
5
  "typings": "index.d.ts",
6
6
  "files": [
@@ -9,14 +9,14 @@
9
9
  "index.d.ts"
10
10
  ],
11
11
  "devDependencies": {
12
- "@midwayjs/core": "^3.4.0-beta.2",
13
- "@midwayjs/decorator": "^3.4.0-beta.2",
14
- "@midwayjs/koa": "^3.4.0-beta.2",
15
- "@midwayjs/mock": "^3.4.0-beta.2",
12
+ "@midwayjs/core": "^3.4.0-beta.5",
13
+ "@midwayjs/decorator": "^3.4.0-beta.5",
14
+ "@midwayjs/koa": "^3.4.0-beta.5",
15
+ "@midwayjs/mock": "^3.4.0-beta.5",
16
16
  "sqlite3": "5.0.8"
17
17
  },
18
18
  "dependencies": {
19
- "sequelize": "6.21.0",
19
+ "sequelize": "6.21.2",
20
20
  "sequelize-typescript": "^2.1.0"
21
21
  },
22
22
  "keywords": [
@@ -41,5 +41,5 @@
41
41
  "type": "git",
42
42
  "url": "http://github.com/midwayjs/midway.git"
43
43
  },
44
- "gitHead": "a61721d3946b30fd4cac183265edcd99b31ac72b"
44
+ "gitHead": "d84d1c77aed1fd973d002ab65cd0adeadb7924a6"
45
45
  }