@blitznocode/blitz-orm 0.14.0 → 0.14.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/index.d.mts +67 -2
- package/dist/index.mjs +59 -50
- package/dist/index.mjs.map +1 -1
- package/package.json +38 -37
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
import { QueryParameters, QueryResult } from 'surrealdb';
|
|
2
2
|
import { TypeDBDriver, TypeDBSession } from 'typedb-driver';
|
|
3
3
|
|
|
4
|
+
type AnySurrealClient = SimpleSurrealClient | SurrealPool;
|
|
5
|
+
declare class SurrealClient {
|
|
6
|
+
private db;
|
|
7
|
+
private url;
|
|
8
|
+
private username;
|
|
9
|
+
private password;
|
|
10
|
+
private namespace;
|
|
11
|
+
private database;
|
|
12
|
+
private connectionPromise;
|
|
13
|
+
private cancelScheduledConnectionCheck;
|
|
14
|
+
private cancelRetrySleep;
|
|
15
|
+
private closed;
|
|
16
|
+
constructor(params: {
|
|
17
|
+
url: string;
|
|
18
|
+
username: string;
|
|
19
|
+
password: string;
|
|
20
|
+
namespace: string;
|
|
21
|
+
database: string;
|
|
22
|
+
});
|
|
23
|
+
close(): Promise<void>;
|
|
24
|
+
connect(): Promise<void>;
|
|
25
|
+
get isClosed(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Connect to SurrealDB if not connected and run the callback.
|
|
28
|
+
*/
|
|
29
|
+
private run;
|
|
30
|
+
private scheduleConnectionCheck;
|
|
31
|
+
/**
|
|
32
|
+
* Try to run the callback until it succeeds or the maximum number of retries is reached.
|
|
33
|
+
* Retry only on engine disconnected errors.
|
|
34
|
+
*/
|
|
35
|
+
private tryRun;
|
|
36
|
+
/**
|
|
37
|
+
* This method should not throw any exception.
|
|
38
|
+
*/
|
|
39
|
+
private tryConnectingUntilSucceed;
|
|
40
|
+
query<T = unknown>(...args: QueryParameters): Promise<T[]>;
|
|
41
|
+
queryRaw<T = unknown>(...args: QueryParameters): Promise<QueryResult<T>[]>;
|
|
42
|
+
}
|
|
43
|
+
declare class SurrealPool {
|
|
44
|
+
private queue;
|
|
45
|
+
private clients;
|
|
46
|
+
private freeClients;
|
|
47
|
+
constructor(params: {
|
|
48
|
+
url: string;
|
|
49
|
+
username: string;
|
|
50
|
+
password: string;
|
|
51
|
+
namespace: string;
|
|
52
|
+
database: string;
|
|
53
|
+
totalConnections: number;
|
|
54
|
+
});
|
|
55
|
+
close(): Promise<void>;
|
|
56
|
+
private dequeue;
|
|
57
|
+
private run;
|
|
58
|
+
query<T = unknown>(...args: QueryParameters): Promise<T[]>;
|
|
59
|
+
queryRaw<T = unknown>(...args: QueryParameters): Promise<QueryResult<T>[]>;
|
|
60
|
+
useClient<T>(cb: (client: SurrealClient) => Promise<T>): Promise<T>;
|
|
61
|
+
}
|
|
4
62
|
declare class SimpleSurrealClient {
|
|
5
63
|
private url;
|
|
6
64
|
private username;
|
|
@@ -16,7 +74,7 @@ declare class SimpleSurrealClient {
|
|
|
16
74
|
});
|
|
17
75
|
private run;
|
|
18
76
|
query<T = unknown>(...args: QueryParameters): Promise<T[]>;
|
|
19
|
-
|
|
77
|
+
queryRaw<T = unknown>(...args: QueryParameters): Promise<QueryResult<T>[]>;
|
|
20
78
|
}
|
|
21
79
|
|
|
22
80
|
type SurrealDBProviderConfig = {
|
|
@@ -29,9 +87,16 @@ interface SurrealDBProviderObject extends CommonProvider {
|
|
|
29
87
|
namespace: string;
|
|
30
88
|
username: string;
|
|
31
89
|
password: string;
|
|
90
|
+
/**
|
|
91
|
+
* The total number of connections to the SurrealDB server.
|
|
92
|
+
* Setting this to a higher number will increase the concurrency of the queries.
|
|
93
|
+
* totalConnections that is too high will cause the connections to drop.
|
|
94
|
+
* The default is 64.
|
|
95
|
+
*/
|
|
96
|
+
totalConnections?: number;
|
|
32
97
|
}
|
|
33
98
|
type SurrealDBHandles = Map<string, {
|
|
34
|
-
client:
|
|
99
|
+
client: AnySurrealClient;
|
|
35
100
|
providerConfig: SurrealDBProviderConfig;
|
|
36
101
|
}>;
|
|
37
102
|
|