mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
[pg] Add Connection abstraction
Only the methods used in the "submit" function from the following projects were declared: * pg-copy-streams * pg-query-stream * pg-cursor
This commit is contained in:
Vendored
+43
@@ -17,6 +17,7 @@ export interface ConnectionConfig {
|
||||
host?: string;
|
||||
connectionString?: string;
|
||||
keepAlive?: boolean;
|
||||
stream?: stream.Duplex;
|
||||
}
|
||||
|
||||
export interface Defaults extends ConnectionConfig {
|
||||
@@ -89,6 +90,48 @@ export interface ResultBuilder extends QueryResult {
|
||||
addRow(row: any): void;
|
||||
}
|
||||
|
||||
export interface QueryParse {
|
||||
name: string;
|
||||
text: string;
|
||||
types: string[];
|
||||
}
|
||||
|
||||
export interface BindConfig {
|
||||
portal?: string;
|
||||
statement?: string;
|
||||
binary?: string;
|
||||
values?: Array<(Buffer | null | undefined | string)>;
|
||||
}
|
||||
|
||||
export interface ExecuteConfig {
|
||||
portal?: string;
|
||||
rows?: string;
|
||||
}
|
||||
|
||||
export interface MessageConfig {
|
||||
type: string;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export class Connection extends events.EventEmitter {
|
||||
readonly stream: stream.Duplex;
|
||||
|
||||
constructor(config?: ConnectionConfig);
|
||||
|
||||
bind(config: BindConfig | null, more: boolean): void;
|
||||
execute(config: ExecuteConfig | null, more: boolean): void;
|
||||
parse(query: QueryParse, more: boolean): void;
|
||||
|
||||
query(text: string): void;
|
||||
|
||||
describe(msg: MessageConfig, more: boolean): void;
|
||||
close(msg: MessageConfig, more: boolean): void;
|
||||
|
||||
flush(): void;
|
||||
sync(): void;
|
||||
end(): void;
|
||||
}
|
||||
|
||||
export class Pool extends events.EventEmitter {
|
||||
// `new Pool('pg://user@localhost/mydb')` is not allowed.
|
||||
// But it passes type check because of issue:
|
||||
|
||||
Reference in New Issue
Block a user