UNPKG

2.42 kBTypeScriptView Raw
1import { Client } from 'pg';
2import { Factory } from 'generic-pool';
3import { DBClient, DBClientConfig } from '../db/DBClient';
4import { DBTransaction } from '../db/DBTransaction';
5import { ConnectionConfig, ConnectionPool } from '../db/ConnectionPool';
6/**
7 * CONFIGURATION OBJECTS
8 */
9export interface PostgresConnectionConfig extends ConnectionConfig {
10 /**
11 * number of milliseconds before a query will time out default is no timeout
12 */
13 statement_timeout?: number;
14 /**
15 * The hostname of the database you are connecting to. (Default: localhost)
16 */
17 host: string;
18 /**
19 * The port number to connect to. (Default: 3306)
20 */
21 port?: number;
22 /**
23 * Name of the database to connect to
24 */
25 database: string;
26 /**
27 * User used to connect
28 */
29 user: string;
30 /**
31 * Password used to authenticate on connection
32 */
33 password: string;
34 /**
35 * The milliseconds before a timeout occurs during the initial connection to the MySQL server. (Default: 10 seconds)
36 */
37 connectTimeout?: number;
38 /**
39 * The source IP address to use for TCP connection
40 */
41 localAddress?: string;
42 /**
43 * The path to a unix domain socket to connect to. When used host and port are ignored
44 */
45 socketPath?: string;
46 /**
47 * The timezone used to store local dates. (Default: 'local')
48 */
49 timezone?: string;
50 /**
51 * object with ssl parameters or a string containing name of ssl profile
52 */
53 ssl?: any;
54 /**
55 * The character set to use in the connection
56 */
57 charset?: string;
58}
59export interface PostgresClientConfiguration extends DBClientConfig<PostgresConnectionConfig> {
60}
61export declare class PostgresTransaction extends DBTransaction<Client> {
62 protected runQueryInConnection(sql: string, bindsArr: Array<any>): Promise<any>;
63}
64/**
65 * A MySQL client you can use to execute queries against MySQL
66 */
67export declare class PostgresClient extends DBClient<Client, PostgresTransaction, PostgresConnectionConfig, PostgresClientConfiguration> {
68 initialise(): Promise<void>;
69 getConnectionFactory(name: string, connectionConfig: PostgresConnectionConfig): Factory<Client>;
70 getNewDBTransaction(readonly: boolean, connectionPool: ConnectionPool<Client>): PostgresTransaction;
71 getPingQuery(): string;
72 getDefaultConnectionConfig(): PostgresConnectionConfig;
73}