@midwayjs/sequelize 3.7.3 → 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.
@@ -22,6 +22,10 @@ let SequelizeConfiguration = class SequelizeConfiguration {
22
22
  this.dataSourceManager.getDataSourceNameByModel(meta.modelKey))
23
23
  .getRepository(meta.modelKey);
24
24
  });
25
+ this.decoratorService.registerPropertyHandler(decorator_1.DATA_SOURCE_KEY, (propertyName, meta) => {
26
+ return this.dataSourceManager.getDataSource(meta.dataSourceName ||
27
+ this.dataSourceManager.getDefaultDataSourceName());
28
+ });
25
29
  }
26
30
  async onReady(container) {
27
31
  this.dataSourceManager = await container.getAsync(dataSourceManager_1.SequelizeDataSourceManager);
@@ -7,7 +7,9 @@ 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 const DATA_SOURCE_KEY = "sequelize:data_source_key";
10
11
  export declare function InjectRepository(modelKey: {
11
12
  new (): Model<any, any>;
12
13
  }, connectionName?: string): PropertyDecorator;
14
+ export declare function InjectDataSource(dataSourceName?: string): PropertyDecorator;
13
15
  //# sourceMappingURL=decorator.d.ts.map
package/dist/decorator.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InjectRepository = exports.ENTITY_MODEL_KEY = exports.BaseTable = void 0;
3
+ exports.InjectDataSource = exports.InjectRepository = exports.DATA_SOURCE_KEY = exports.ENTITY_MODEL_KEY = exports.BaseTable = void 0;
4
4
  const core_1 = require("@midwayjs/core");
5
5
  const sequelize_typescript_1 = require("sequelize-typescript");
6
6
  function BaseTable(arg) {
@@ -22,6 +22,7 @@ function annotate(target, options = {}) {
22
22
  (0, sequelize_typescript_1.addOptions)(target.prototype, options);
23
23
  }
24
24
  exports.ENTITY_MODEL_KEY = 'sequelize:entity_model_key';
25
+ exports.DATA_SOURCE_KEY = 'sequelize:data_source_key';
25
26
  function InjectRepository(modelKey, connectionName) {
26
27
  return (0, core_1.createCustomPropertyDecorator)(exports.ENTITY_MODEL_KEY, {
27
28
  modelKey,
@@ -29,4 +30,10 @@ function InjectRepository(modelKey, connectionName) {
29
30
  });
30
31
  }
31
32
  exports.InjectRepository = InjectRepository;
33
+ function InjectDataSource(dataSourceName) {
34
+ return (0, core_1.createCustomPropertyDecorator)(exports.DATA_SOURCE_KEY, {
35
+ dataSourceName,
36
+ });
37
+ }
38
+ exports.InjectDataSource = InjectDataSource;
32
39
  //# sourceMappingURL=decorator.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/sequelize",
3
- "version": "3.7.3",
3
+ "version": "3.8.0",
4
4
  "main": "dist/index",
5
5
  "typings": "index.d.ts",
6
6
  "files": [
@@ -9,10 +9,10 @@
9
9
  "index.d.ts"
10
10
  ],
11
11
  "devDependencies": {
12
- "@midwayjs/core": "^3.7.0",
13
- "@midwayjs/koa": "^3.7.3",
14
- "@midwayjs/mock": "^3.7.3",
15
- "sequelize": "6.25.3",
12
+ "@midwayjs/core": "^3.8.0",
13
+ "@midwayjs/koa": "^3.8.0",
14
+ "@midwayjs/mock": "^3.8.0",
15
+ "sequelize": "6.25.6",
16
16
  "sequelize-typescript": "2.1.5",
17
17
  "sqlite3": "5.1.2"
18
18
  },
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "repository": {
38
38
  "type": "git",
39
- "url": "http://github.com/midwayjs/midway.git"
39
+ "url": "https://github.com/midwayjs/midway.git"
40
40
  },
41
- "gitHead": "8e6c830bca52818e0086873b542423d16e609aef"
41
+ "gitHead": "5c640c7182923587139f9f9c0aecf50585798e1e"
42
42
  }