UNPKG

1.02 kBTypeScriptView Raw
1import { Promise } from './promise';
2
3export interface GetConnectionOptions {
4 /**
5 * Set which replica to use. Available options are `read` and `write`
6 */
7 type: 'read' | 'write';
8 /**
9 * Force master or write replica to get connection from
10 */
11 useMaster?: boolean;
12}
13
14export type Connection = object;
15
16export interface ConnectionManager {
17 refreshTypeParser(dataTypes: object): void;
18 /**
19 * Drain the pool and close it permanently
20 */
21 close(): Promise<void>;
22 /**
23 * Initialize connection pool. By default pool autostart is set to false, so no connection will be
24 * be created unless `pool.acquire` is called.
25 */
26 initPools(): void;
27 /**
28 * Get connection from pool. It sets database version if it's not already set.
29 * Call pool.acquire to get a connection.
30 */
31 getConnection(opts: GetConnectionOptions): Promise<Connection>;
32 /**
33 * Release a pooled connection so it can be utilized by other connection requests
34 */
35 releaseConnection(conn: Connection): Promise<void>;
36}