oak-db 3.3.5 → 3.3.7
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.d.ts +15 -15
- package/lib/MySQL/store.d.ts +36 -36
- package/lib/MySQL/store.js +2 -1
- package/lib/MySQL/translator.js +1 -1
- package/lib/sqlTranslator.js +982 -982
- package/package.json +2 -2
package/lib/MySQL/connector.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import mysql, { Pool } from 'mysql2/promise';
|
|
2
|
-
import { TxnOption } from 'oak-domain/lib/types';
|
|
3
|
-
import { MySQLConfiguration } from './types/Configuration';
|
|
4
|
-
export declare class MySqlConnector {
|
|
5
|
-
pool: Pool;
|
|
6
|
-
configuration: MySQLConfiguration;
|
|
7
|
-
txnDict: Record<string, mysql.PoolConnection>;
|
|
8
|
-
constructor(configuration: MySQLConfiguration);
|
|
9
|
-
connect(): void;
|
|
10
|
-
disconnect(): Promise<void>;
|
|
11
|
-
startTransaction(option?: TxnOption): Promise<string>;
|
|
12
|
-
exec(sql: string, txn?: string): Promise<[mysql.RowDataPacket[] | mysql.RowDataPacket[][] | mysql.OkPacket | mysql.OkPacket[] | mysql.ResultSetHeader, mysql.FieldPacket[]]>;
|
|
13
|
-
commitTransaction(txn: string): Promise<void>;
|
|
14
|
-
rollbackTransaction(txn: string): Promise<void>;
|
|
15
|
-
}
|
|
1
|
+
import mysql, { Pool } from 'mysql2/promise';
|
|
2
|
+
import { TxnOption } from 'oak-domain/lib/types';
|
|
3
|
+
import { MySQLConfiguration } from './types/Configuration';
|
|
4
|
+
export declare class MySqlConnector {
|
|
5
|
+
pool: Pool;
|
|
6
|
+
configuration: MySQLConfiguration;
|
|
7
|
+
txnDict: Record<string, mysql.PoolConnection>;
|
|
8
|
+
constructor(configuration: MySQLConfiguration);
|
|
9
|
+
connect(): void;
|
|
10
|
+
disconnect(): Promise<void>;
|
|
11
|
+
startTransaction(option?: TxnOption): Promise<string>;
|
|
12
|
+
exec(sql: string, txn?: string): Promise<[mysql.RowDataPacket[] | mysql.RowDataPacket[][] | mysql.OkPacket | mysql.OkPacket[] | mysql.ResultSetHeader, mysql.FieldPacket[]]>;
|
|
13
|
+
commitTransaction(txn: string): Promise<void>;
|
|
14
|
+
rollbackTransaction(txn: string): Promise<void>;
|
|
15
|
+
}
|
package/lib/MySQL/store.d.ts
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { EntityDict, OperateOption, OperationResult, TxnOption, StorageSchema, SelectOption, AggregationResult } from 'oak-domain/lib/types';
|
|
2
|
-
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
|
3
|
-
import { CascadeStore } from 'oak-domain/lib/store/CascadeStore';
|
|
4
|
-
import { MySQLConfiguration } from './types/Configuration';
|
|
5
|
-
import { MySqlConnector } from './connector';
|
|
6
|
-
import { MySqlTranslator, MySqlSelectOption, MysqlOperateOption } from './translator';
|
|
7
|
-
import { AsyncContext, AsyncRowStore } from 'oak-domain/lib/store/AsyncRowStore';
|
|
8
|
-
import { SyncContext } from 'oak-domain/lib/store/SyncRowStore';
|
|
9
|
-
import { CreateEntityOption } from '../types/Translator';
|
|
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
|
-
exec(script: string, txnId?: string): Promise<void>;
|
|
16
|
-
connector: MySqlConnector;
|
|
17
|
-
translator: MySqlTranslator<ED>;
|
|
18
|
-
constructor(storageSchema: StorageSchema<ED>, configuration: MySQLConfiguration);
|
|
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
|
-
aggregate<T extends keyof ED, OP extends SelectOption>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): Promise<AggregationResult<ED[T]['Schema']>>;
|
|
21
|
-
protected supportManyToOneJoin(): boolean;
|
|
22
|
-
protected supportMultipleCreate(): boolean;
|
|
23
|
-
private formResult;
|
|
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
|
-
operate<T extends keyof ED>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: OperateOption): Promise<OperationResult<ED>>;
|
|
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: AsyncContext<ED>, option: SelectOption): Promise<number>;
|
|
29
|
-
count<T extends keyof ED>(entity: T, selection: Pick<ED[T]['Selection'], 'filter' | 'count'>, context: Cxt, option: SelectOption): Promise<number>;
|
|
30
|
-
begin(option?: TxnOption): Promise<string>;
|
|
31
|
-
commit(txnId: string): Promise<void>;
|
|
32
|
-
rollback(txnId: string): Promise<void>;
|
|
33
|
-
connect(): void;
|
|
34
|
-
disconnect(): Promise<void>;
|
|
35
|
-
initialize(option: CreateEntityOption): Promise<void>;
|
|
36
|
-
}
|
|
1
|
+
import { EntityDict, OperateOption, OperationResult, TxnOption, StorageSchema, SelectOption, AggregationResult } from 'oak-domain/lib/types';
|
|
2
|
+
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
|
3
|
+
import { CascadeStore } from 'oak-domain/lib/store/CascadeStore';
|
|
4
|
+
import { MySQLConfiguration } from './types/Configuration';
|
|
5
|
+
import { MySqlConnector } from './connector';
|
|
6
|
+
import { MySqlTranslator, MySqlSelectOption, MysqlOperateOption } from './translator';
|
|
7
|
+
import { AsyncContext, AsyncRowStore } from 'oak-domain/lib/store/AsyncRowStore';
|
|
8
|
+
import { SyncContext } from 'oak-domain/lib/store/SyncRowStore';
|
|
9
|
+
import { CreateEntityOption } from '../types/Translator';
|
|
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
|
+
exec(script: string, txnId?: string): Promise<void>;
|
|
16
|
+
connector: MySqlConnector;
|
|
17
|
+
translator: MySqlTranslator<ED>;
|
|
18
|
+
constructor(storageSchema: StorageSchema<ED>, configuration: MySQLConfiguration);
|
|
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
|
+
aggregate<T extends keyof ED, OP extends SelectOption>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): Promise<AggregationResult<ED[T]['Schema']>>;
|
|
21
|
+
protected supportManyToOneJoin(): boolean;
|
|
22
|
+
protected supportMultipleCreate(): boolean;
|
|
23
|
+
private formResult;
|
|
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
|
+
operate<T extends keyof ED>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: OperateOption): Promise<OperationResult<ED>>;
|
|
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: AsyncContext<ED>, option: SelectOption): Promise<number>;
|
|
29
|
+
count<T extends keyof ED>(entity: T, selection: Pick<ED[T]['Selection'], 'filter' | 'count'>, context: Cxt, option: SelectOption): Promise<number>;
|
|
30
|
+
begin(option?: TxnOption): Promise<string>;
|
|
31
|
+
commit(txnId: string): Promise<void>;
|
|
32
|
+
rollback(txnId: string): Promise<void>;
|
|
33
|
+
connect(): void;
|
|
34
|
+
disconnect(): Promise<void>;
|
|
35
|
+
initialize(option: CreateEntityOption): Promise<void>;
|
|
36
|
+
}
|
package/lib/MySQL/store.js
CHANGED
|
@@ -11,8 +11,9 @@ const relation_1 = require("oak-domain/lib/store/relation");
|
|
|
11
11
|
function convertGeoTextToObject(geoText) {
|
|
12
12
|
if (geoText.startsWith('POINT')) {
|
|
13
13
|
const coord = geoText.match((/(\d|\.)+(?=\)|\s)/g));
|
|
14
|
+
(0, assert_1.default)(coord.length === 2);
|
|
14
15
|
return {
|
|
15
|
-
type: '
|
|
16
|
+
type: 'point',
|
|
16
17
|
coordinate: coord.map(ele => parseFloat(ele)),
|
|
17
18
|
};
|
|
18
19
|
}
|
package/lib/MySQL/translator.js
CHANGED
|
@@ -907,7 +907,7 @@ class MySqlTranslator extends sqlTranslator_1.SqlTranslator {
|
|
|
907
907
|
// todo using index
|
|
908
908
|
const alias = aliasDict['./'];
|
|
909
909
|
if (option?.deletePhysically) {
|
|
910
|
-
|
|
910
|
+
// assert(!updateText, 'physically delete does not support setting trigger data');
|
|
911
911
|
let sql = `delete ${alias} from ${fromText} `;
|
|
912
912
|
if (filterText) {
|
|
913
913
|
sql += ` where ${filterText}`;
|