@e-mc/db 0.8.3 → 0.8.4
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/README.md +101 -3
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,7 +1,105 @@
|
|
|
1
|
-
|
|
1
|
+
# @e-mc/db
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
* NodeJS 14
|
|
4
|
+
* ES2020
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
## General Usage
|
|
7
|
+
|
|
8
|
+
* [Read the Docs](https://e-mc.readthedocs.io)
|
|
9
|
+
|
|
10
|
+
## Interface
|
|
11
|
+
|
|
12
|
+
- https://www.unpkg.com/@e-mc/types@0.8.4/lib/index.d.ts
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
import type { DbDataSource } from "./squared";
|
|
16
|
+
|
|
17
|
+
import type { IHost } from "./index";
|
|
18
|
+
import type { ClientDbConstructor, IClientDb } from "./core";
|
|
19
|
+
import type { BatchQueryResult, DB_TYPE, ExecuteBatchQueryOptions, ExecuteQueryOptions, HandleFailOptions, PoolConfig, ProcessRowsOptions, QueryResult, SQL_COMMAND } from "./db";
|
|
20
|
+
import type { DbCoerceSettings, DbModule, DbSourceOptions } from "./settings";
|
|
21
|
+
|
|
22
|
+
import type { SecureContextOptions } from "tls";
|
|
23
|
+
|
|
24
|
+
interface IDb extends IClientDb<IHost, DbModule, DbDataSource, DbSourceOptions, DbCoerceSettings> {
|
|
25
|
+
setCredential(item: DbDataSource): Promise<void>;
|
|
26
|
+
getCredential(item: DbDataSource): Record<string | number | symbol, unknown>;
|
|
27
|
+
hasSource(source: string, ...type: number[]): boolean;
|
|
28
|
+
applyCommand(...items: DbDataSource[]): void;
|
|
29
|
+
executeQuery(item: DbDataSource, sessionKey: string): Promise<QueryResult>;
|
|
30
|
+
executeQuery(item: DbDataSource, options?: ExecuteQueryOptions | string): Promise<QueryResult>;
|
|
31
|
+
executeBatchQuery(batch: DbDataSource[], sessionKey: string, outResult?: BatchQueryResult): Promise<BatchQueryResult>;
|
|
32
|
+
executeBatchQuery(batch: DbDataSource[], options?: ExecuteBatchQueryOptions | string, outResult?: BatchQueryResult): Promise<BatchQueryResult>;
|
|
33
|
+
processRows(batch: DbDataSource[], tasks: Promise<QueryResult | null>[], parallel: boolean): Promise<BatchQueryResult>;
|
|
34
|
+
processRows(batch: DbDataSource[], tasks: Promise<QueryResult | null>[], options?: ProcessRowsOptions, outResult?: BatchQueryResult): Promise<BatchQueryResult>;
|
|
35
|
+
handleFail(err: unknown, item: DbDataSource, options?: HandleFailOptions): boolean;
|
|
36
|
+
readTLSCert(value: unknown, cache?: boolean): string;
|
|
37
|
+
readTLSConfig(options: SecureContextOptions, cache?: boolean): void;
|
|
38
|
+
settingsOf(source: string, name: keyof Omit<DbSourceOptions, "coerce">): unknown;
|
|
39
|
+
settingsOf(source: string, name: "coerce", component: keyof DbCoerceSettings): unknown;
|
|
40
|
+
settingsKey(source: string, name: keyof Omit<DbSourceOptions, "coerce">): unknown;
|
|
41
|
+
settingsKey(source: string, name: "coerce", component: keyof DbCoerceSettings): unknown;
|
|
42
|
+
getPoolConfig(source: string, uuidKey?: string): Required<PoolConfig> | undefined;
|
|
43
|
+
get sourceType(): DB_TYPE;
|
|
44
|
+
get commandType(): SQL_COMMAND;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface DbConstructor extends ClientDbConstructor<IHost> {
|
|
48
|
+
setPoolConfig(value: Record<string, PoolConfig>): void;
|
|
49
|
+
getPoolConfig(source: string): Required<PoolConfig> | undefined;
|
|
50
|
+
readonly prototype: IDb;
|
|
51
|
+
new(module?: DbModule, database?: DbDataSource[], ...args: unknown[]): IDb;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface IDbSourceClient {
|
|
55
|
+
DB_SOURCE_NAME: string;
|
|
56
|
+
DB_SOURCE_CLIENT: boolean;
|
|
57
|
+
DB_SOURCE_TYPE: number;
|
|
58
|
+
setCredential(this: IDb, item: DbDataSource): Promise<void>;
|
|
59
|
+
executeQuery(this: IDb, item: DbDataSource, options?: ExecuteQueryOptions | string): Promise<QueryResult>;
|
|
60
|
+
executeBatchQuery(this: IDb, batch: DbDataSource[], options?: ExecuteBatchQueryOptions | string, outResult?: BatchQueryResult): Promise<BatchQueryResult>;
|
|
61
|
+
checkTimeout?(this: IDbSourceClient, value: number, limit?: number): Promise<number>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface IDbPool {
|
|
65
|
+
client: unknown;
|
|
66
|
+
lastAccessed: number;
|
|
67
|
+
success: number;
|
|
68
|
+
failed: number;
|
|
69
|
+
poolKey: string;
|
|
70
|
+
uuidKey: AuthValue | null;
|
|
71
|
+
add(item: DbDataSource, uuidKey?: string): this;
|
|
72
|
+
has(item: DbDataSource): boolean;
|
|
73
|
+
getConnection(): Promise<unknown>;
|
|
74
|
+
remove(): void;
|
|
75
|
+
detach(force?: boolean): Promise<void>;
|
|
76
|
+
close(): Promise<void>;
|
|
77
|
+
isIdle(timeout: number): boolean;
|
|
78
|
+
isEmpty(): boolean;
|
|
79
|
+
set connected(value: boolean);
|
|
80
|
+
get persist(): boolean;
|
|
81
|
+
get closed(): boolean;
|
|
82
|
+
get closeable(): boolean;
|
|
83
|
+
set parent(value: Record<string, IDbPool>);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
interface DbPoolConstructor {
|
|
87
|
+
findKey(pools: Record<string, IDbPool>, uuidKey: unknown, poolKey: string | undefined, ...items: DbDataSource[]): Record<string, IDbPool> | null;
|
|
88
|
+
validateKey(pools: Record<string, IDbPool>, username: string, uuidKey: unknown): [string, Record<string, IDbPool> | null];
|
|
89
|
+
checkTimeout(pools: Record<string, IDbPool>, value: number, limit?: number): Promise<number>;
|
|
90
|
+
readonly prototype: IDbPool;
|
|
91
|
+
new(pool: unknown, poolKey: string, uuidKey?: AuthValue | null): IDbPool;
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## References
|
|
96
|
+
|
|
97
|
+
- https://www.unpkg.com/@e-mc/types@0.8.4/lib/squared.d.ts
|
|
98
|
+
- https://www.unpkg.com/@e-mc/types@0.8.4/lib/core.d.ts
|
|
99
|
+
- https://www.unpkg.com/@e-mc/types@0.8.4/lib/db.d.ts
|
|
100
|
+
- https://www.unpkg.com/@e-mc/types@0.8.4/lib/object.d.ts
|
|
101
|
+
- https://www.unpkg.com/@e-mc/types@0.8.4/lib/settings.d.ts
|
|
102
|
+
|
|
103
|
+
## LICENSE
|
|
6
104
|
|
|
7
105
|
BSD 3-Clause
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/db",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"description": "DB modules for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"license": "BSD 3-Clause",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/core": "0.8.
|
|
24
|
-
"@e-mc/request": "0.8.
|
|
25
|
-
"@e-mc/types": "0.8.
|
|
23
|
+
"@e-mc/core": "0.8.4",
|
|
24
|
+
"@e-mc/request": "0.8.4",
|
|
25
|
+
"@e-mc/types": "0.8.4"
|
|
26
26
|
}
|
|
27
27
|
}
|