@midwayjs/typeorm 4.0.0-alpha.1 → 4.0.0-beta.2
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
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DataSourceManager, IMidwayContainer, MidwayLoggerService } from '@midwayjs/core';
|
|
2
2
|
import { DataSource } from 'typeorm';
|
|
3
|
+
import { typeormConfigOptions } from './interface';
|
|
3
4
|
export declare class TypeORMDataSourceManager extends DataSourceManager<DataSource> {
|
|
4
|
-
typeormConfig:
|
|
5
|
+
typeormConfig: typeormConfigOptions;
|
|
5
6
|
applicationContext: IMidwayContainer;
|
|
6
|
-
baseDir: string;
|
|
7
7
|
loggerService: MidwayLoggerService;
|
|
8
8
|
init(): Promise<void>;
|
|
9
9
|
getName(): string;
|
|
@@ -15,19 +15,30 @@ const typeorm_1 = require("typeorm");
|
|
|
15
15
|
const logger_1 = require("./logger");
|
|
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, {
|
|
19
|
+
concurrent: true,
|
|
20
|
+
});
|
|
19
21
|
}
|
|
20
22
|
getName() {
|
|
21
23
|
return 'typeorm';
|
|
22
24
|
}
|
|
23
25
|
async createDataSource(config, dataSourceName) {
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
+
if (!this.typeormConfig['allowExecuteMigrations']) {
|
|
27
|
+
if (config['migrations']) {
|
|
28
|
+
delete config['migrations'];
|
|
29
|
+
}
|
|
26
30
|
}
|
|
27
31
|
if (config['logging'] === undefined) {
|
|
28
32
|
config['logger'] = new logger_1.TypeORMLogger(this.loggerService.getLogger('typeormLogger'));
|
|
29
33
|
}
|
|
30
|
-
const
|
|
34
|
+
const { customDataSourceClass, ...otherConfig } = config;
|
|
35
|
+
let dataSource;
|
|
36
|
+
if (customDataSourceClass) {
|
|
37
|
+
dataSource = new customDataSourceClass(otherConfig);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
dataSource = new typeorm_1.DataSource(otherConfig);
|
|
41
|
+
}
|
|
31
42
|
await dataSource.initialize();
|
|
32
43
|
return dataSource;
|
|
33
44
|
}
|
|
@@ -49,10 +60,6 @@ __decorate([
|
|
|
49
60
|
(0, core_1.ApplicationContext)(),
|
|
50
61
|
__metadata("design:type", Object)
|
|
51
62
|
], TypeORMDataSourceManager.prototype, "applicationContext", void 0);
|
|
52
|
-
__decorate([
|
|
53
|
-
(0, core_1.Inject)(),
|
|
54
|
-
__metadata("design:type", String)
|
|
55
|
-
], TypeORMDataSourceManager.prototype, "baseDir", void 0);
|
|
56
63
|
__decorate([
|
|
57
64
|
(0, core_1.Inject)(),
|
|
58
65
|
__metadata("design:type", core_1.MidwayLoggerService)
|
package/dist/interface.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { DataSourceOptions } from 'typeorm';
|
|
2
2
|
import { DataSourceManagerConfigOption } from '@midwayjs/core';
|
|
3
|
-
export type typeormConfigOptions = DataSourceManagerConfigOption<DataSourceOptions
|
|
3
|
+
export type typeormConfigOptions = DataSourceManagerConfigOption<DataSourceOptions> & {
|
|
4
|
+
allowExecuteMigrations: boolean;
|
|
5
|
+
};
|
|
4
6
|
//# sourceMappingURL=interface.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/typeorm",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-beta.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "index.d.ts",
|
|
6
6
|
"bin": {
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"index.d.ts"
|
|
14
14
|
],
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@midwayjs/core": "^4.0.0-
|
|
17
|
-
"@midwayjs/mock": "^4.0.0-
|
|
16
|
+
"@midwayjs/core": "^4.0.0-beta.2",
|
|
17
|
+
"@midwayjs/mock": "^4.0.0-beta.2",
|
|
18
18
|
"sqlite3": "5.1.7",
|
|
19
19
|
"typeorm": "0.3.20"
|
|
20
20
|
},
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"email": "czy88840616@gmail.com"
|
|
24
24
|
},
|
|
25
25
|
"engines": {
|
|
26
|
-
"node": ">=
|
|
26
|
+
"node": ">=20"
|
|
27
27
|
},
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"scripts": {
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"type": "git",
|
|
36
36
|
"url": "https://github.com/midwayjs/midway.git"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "53bfef4c5279da5f09025e4610bdbf64f94f60bd"
|
|
39
39
|
}
|