forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
promise-pg.d.ts
61 lines (44 loc) · 1.82 KB
/
promise-pg.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Type definitions for promise-pg
// Project: https://bitbucket.org/lplabs/promise-pg
// Definitions by: Chris Charabaruk <http://github.com/coldacid>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
/// <reference path="../q/Q.d.ts" />
/// <reference path="../pg/pg.d.ts" />
declare module "promise-pg" {
import * as stream from 'stream';
import * as pg from 'pg';
export {pg as raw};
export interface ClientConfig extends pg.ClientConfig {}
export function connect(connection: string): Q.Promise<Client>;
export function connect(connection: pg.ClientConfig): Q.Promise<Client>;
export function end(): Q.Promise<void>;
export interface QueryConfig extends pg.QueryConfig {
buffer?: boolean;
}
export class Client {
constructor(connection: string);
constructor(config: ClientConfig);
raw: pg.Client;
connect(): Q.Promise<void>;
end(): Q.Promise<void>;
query(queryText: string): Query;
query(config: QueryConfig): Query;
query(queryText: string, values: any[]): Query;
copyFrom(queryText: string): stream.Writable;
copyTo(queryText: string): stream.Readable;
pauseDrain(): void;
resumeDrain(): void;
public on(event: "drain", listener: () => void): Client;
public on(event: "error", listener: (err: Error) => void): Client;
public on(event: "notification", listener: (message: any) => void): Client;
public on(event: "notice", listener: (message: any) => void): Client;
public on(event: string, listener: Function): Client;
transaction(task: () => Q.Promise<any>): Q.Promise<any>;
}
export interface QueryResult extends pg.QueryResult {}
export interface ResultBuilder extends pg.ResultBuilder {}
export class Query extends pg.Query {
promise: Q.Promise<QueryResult>;
}
}