oak-db 3.2.1 → 3.3.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.
- package/lib/MySQL/connector.js +5 -6
- package/lib/MySQL/store.d.ts +11 -11
- package/lib/MySQL/types/Configuration.d.ts +1 -0
- package/lib/MySQL/types/Configuration.js +2 -2
- package/lib/index.d.ts +2 -2
- package/lib/index.js +4 -4
- package/lib/sqlTranslator.js +982 -982
- package/package.json +3 -3
package/lib/MySQL/connector.js
CHANGED
|
@@ -20,6 +20,7 @@ class MySqlConnector {
|
|
|
20
20
|
return this.pool.end();
|
|
21
21
|
}
|
|
22
22
|
async startTransaction(option) {
|
|
23
|
+
// 防止用户配置connection可复用
|
|
23
24
|
const startInner = async () => {
|
|
24
25
|
const connection = await this.pool.getConnection();
|
|
25
26
|
// 分配出来的connection不能被别的事务占据
|
|
@@ -32,7 +33,7 @@ class MySqlConnector {
|
|
|
32
33
|
}
|
|
33
34
|
await connection.beginTransaction();
|
|
34
35
|
const id = (0, uuid_1.v4)();
|
|
35
|
-
console.log('start_txn', id, connection.threadId);
|
|
36
|
+
// console.log('start_txn', id, connection.threadId);
|
|
36
37
|
this.txnDict[id] = connection;
|
|
37
38
|
if (option?.isolationLevel) {
|
|
38
39
|
await connection.query(`SET TRANSACTION ISOLATION LEVEL ${option.isolationLevel};`);
|
|
@@ -58,18 +59,16 @@ class MySqlConnector {
|
|
|
58
59
|
}
|
|
59
60
|
async commitTransaction(txn) {
|
|
60
61
|
const connection = this.txnDict[txn];
|
|
61
|
-
|
|
62
|
-
console.log('qiguai!');
|
|
63
|
-
}
|
|
62
|
+
(0, assert_1.default)(connection);
|
|
64
63
|
delete this.txnDict[txn];
|
|
65
|
-
console.log('commit_txn', txn, connection.threadId);
|
|
64
|
+
// console.log('commit_txn', txn, connection.threadId);
|
|
66
65
|
await connection.commit();
|
|
67
66
|
connection.release();
|
|
68
67
|
}
|
|
69
68
|
async rollbackTransaction(txn) {
|
|
70
69
|
const connection = this.txnDict[txn];
|
|
71
70
|
(0, assert_1.default)(connection);
|
|
72
|
-
console.log('rollback_txn', txn, connection.threadId);
|
|
71
|
+
// console.log('rollback_txn', txn, connection.threadId);
|
|
73
72
|
await connection.rollback();
|
|
74
73
|
delete this.txnDict[txn];
|
|
75
74
|
connection.release();
|
package/lib/MySQL/store.d.ts
CHANGED
|
@@ -4,28 +4,28 @@ import { CascadeStore } from 'oak-domain/lib/store/CascadeStore';
|
|
|
4
4
|
import { MySQLConfiguration } from './types/Configuration';
|
|
5
5
|
import { MySqlConnector } from './connector';
|
|
6
6
|
import { MySqlTranslator, MySqlSelectOption, MysqlOperateOption } from './translator';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { AsyncContext, AsyncRowStore } from 'oak-domain/lib/store/AsyncRowStore';
|
|
8
|
+
import { SyncContext } from 'oak-domain/lib/store/SyncRowStore';
|
|
9
9
|
import { CreateEntityOption } from '../types/Translator';
|
|
10
|
-
export declare class MysqlStore<ED extends EntityDict & BaseEntityDict, Cxt extends
|
|
11
|
-
protected countAbjointRow<T extends keyof ED, OP extends SelectOption, Cxt extends
|
|
12
|
-
protected aggregateAbjointRowSync<T extends keyof ED, OP extends SelectOption, Cxt extends
|
|
13
|
-
protected selectAbjointRow<T extends keyof ED, OP extends SelectOption>(entity: T, selection: ED[T]['Selection'], context:
|
|
14
|
-
protected updateAbjointRow<T extends keyof ED, OP extends OperateOption>(entity: T, operation: ED[T]['Operation'], context:
|
|
10
|
+
export declare class MysqlStore<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>> extends CascadeStore<ED> implements AsyncRowStore<ED, Cxt> {
|
|
11
|
+
protected countAbjointRow<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED>>(entity: T, selection: Pick<ED[T]['Selection'], 'filter' | 'count'>, context: Cxt, option: OP): number;
|
|
12
|
+
protected aggregateAbjointRowSync<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED>>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): AggregationResult<ED[T]['Schema']>;
|
|
13
|
+
protected selectAbjointRow<T extends keyof ED, OP extends SelectOption>(entity: T, selection: ED[T]['Selection'], context: SyncContext<ED>, option: OP): Partial<ED[T]['Schema']>[];
|
|
14
|
+
protected updateAbjointRow<T extends keyof ED, OP extends OperateOption>(entity: T, operation: ED[T]['Operation'], context: SyncContext<ED>, option: OP): number;
|
|
15
15
|
exec(script: string, txnId?: string): Promise<any>;
|
|
16
16
|
connector: MySqlConnector;
|
|
17
17
|
translator: MySqlTranslator<ED>;
|
|
18
18
|
constructor(storageSchema: StorageSchema<ED>, configuration: MySQLConfiguration);
|
|
19
|
-
protected aggregateAbjointRowAsync<T extends keyof ED, OP extends SelectOption, Cxt extends
|
|
19
|
+
protected aggregateAbjointRowAsync<T extends keyof ED, OP extends SelectOption, Cxt extends AsyncContext<ED>>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): Promise<AggregationResult<ED[T]['Schema']>>;
|
|
20
20
|
aggregate<T extends keyof ED, OP extends SelectOption>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): Promise<AggregationResult<ED[T]['Schema']>>;
|
|
21
21
|
protected supportManyToOneJoin(): boolean;
|
|
22
22
|
protected supportMultipleCreate(): boolean;
|
|
23
23
|
private formResult;
|
|
24
|
-
protected selectAbjointRowAsync<T extends keyof ED>(entity: T, selection: ED[T]['Selection'], context:
|
|
25
|
-
protected updateAbjointRowAsync<T extends keyof ED>(entity: T, operation: ED[T]['Operation'], context:
|
|
24
|
+
protected selectAbjointRowAsync<T extends keyof ED>(entity: T, selection: ED[T]['Selection'], context: AsyncContext<ED>, option?: MySqlSelectOption): Promise<Partial<ED[T]['Schema']>[]>;
|
|
25
|
+
protected updateAbjointRowAsync<T extends keyof ED>(entity: T, operation: ED[T]['Operation'], context: AsyncContext<ED>, option?: MysqlOperateOption): Promise<number>;
|
|
26
26
|
operate<T extends keyof ED>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: OperateOption): Promise<OperationResult<ED>>;
|
|
27
27
|
select<T extends keyof ED>(entity: T, selection: ED[T]['Selection'], context: Cxt, option: SelectOption): Promise<Partial<ED[T]['Schema']>[]>;
|
|
28
|
-
protected countAbjointRowAsync<T extends keyof ED>(entity: T, selection: Pick<ED[T]['Selection'], 'filter' | 'count'>, context:
|
|
28
|
+
protected countAbjointRowAsync<T extends keyof ED>(entity: T, selection: Pick<ED[T]['Selection'], 'filter' | 'count'>, context: AsyncContext<ED>, option: SelectOption): Promise<number>;
|
|
29
29
|
count<T extends keyof ED>(entity: T, selection: Pick<ED[T]['Selection'], 'filter' | 'count'>, context: Cxt, option: SelectOption): Promise<number>;
|
|
30
30
|
begin(option?: TxnOption): Promise<string>;
|
|
31
31
|
commit(txnId: string): Promise<void>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/lib/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './MySQL/store';
|
|
2
|
-
export { MySqlSelectOption, MysqlOperateOption } from './MySQL/translator';
|
|
1
|
+
export * from './MySQL/store';
|
|
2
|
+
export { MySqlSelectOption, MysqlOperateOption } from './MySQL/translator';
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./MySQL/store"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./MySQL/store"), exports);
|