@midwayjs/core 3.4.9 → 3.4.10

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,38 +18,36 @@ class DataSourceManager {
18
18
  }
19
19
  async initDataSource(options, appDir) {
20
20
  this.options = options;
21
- if (options.dataSource) {
22
- for (const dataSourceName in options.dataSource) {
23
- const dataSourceOptions = options.dataSource[dataSourceName];
24
- if (dataSourceOptions['entities']) {
25
- const entities = new Set();
26
- // loop entities and glob files to model
27
- for (const entity of dataSourceOptions['entities']) {
28
- if (typeof entity === 'string') {
29
- // string will be glob file
30
- const models = globModels(entity, appDir);
31
- for (const model of models) {
32
- entities.add(model);
33
- this.modelMapping.set(model, dataSourceName);
34
- }
35
- }
36
- else {
37
- // model will be add to array
38
- entities.add(entity);
39
- this.modelMapping.set(entity, dataSourceName);
21
+ if (!options.dataSource) {
22
+ throw new error_1.MidwayParameterError('DataSourceManager must set options.dataSource.');
23
+ }
24
+ for (const dataSourceName in options.dataSource) {
25
+ const dataSourceOptions = options.dataSource[dataSourceName];
26
+ if (dataSourceOptions['entities']) {
27
+ const entities = new Set();
28
+ // loop entities and glob files to model
29
+ for (const entity of dataSourceOptions['entities']) {
30
+ if (typeof entity === 'string') {
31
+ // string will be glob file
32
+ const models = globModels(entity, appDir);
33
+ for (const model of models) {
34
+ entities.add(model);
35
+ this.modelMapping.set(model, dataSourceName);
40
36
  }
41
37
  }
42
- dataSourceOptions['entities'] = Array.from(entities);
38
+ else {
39
+ // model will be add to array
40
+ entities.add(entity);
41
+ this.modelMapping.set(entity, dataSourceName);
42
+ }
43
43
  }
44
- // create data source
45
- const opts = {
46
- cacheInstance: options.cacheInstance, // will default true
47
- };
48
- await this.createInstance(dataSourceOptions, dataSourceName, opts);
44
+ dataSourceOptions['entities'] = Array.from(entities);
49
45
  }
50
- }
51
- else {
52
- throw new error_1.MidwayParameterError('DataSourceManager must set options.dataSource.');
46
+ // create data source
47
+ const opts = {
48
+ cacheInstance: options.cacheInstance, // will default true
49
+ };
50
+ await this.createInstance(dataSourceOptions, dataSourceName, opts);
53
51
  }
54
52
  }
55
53
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/core",
3
- "version": "3.4.9",
3
+ "version": "3.4.10",
4
4
  "description": "midway core",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index.d.ts",
@@ -45,5 +45,5 @@
45
45
  "engines": {
46
46
  "node": ">=12"
47
47
  },
48
- "gitHead": "bc8113cff70d88a31e44bde69c395f61a7de2045"
48
+ "gitHead": "aeb117633ecbc3299002b220f436dc3b5450d361"
49
49
  }