Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions types/pg/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ export class Pool extends events.EventEmitter {
export class ClientBase extends events.EventEmitter {
constructor(config?: string | ClientConfig);

connect(): Promise<void>;
connect(callback: (err: Error) => void): void;
connect(): Promise<ClientBase>;
connect(callback: ((err: Error) => void) | ((err: null, c: ClientBase) => void)): void;

query<T extends Submittable>(queryStream: T): T;
// tslint:disable:no-unnecessary-generics
Expand Down Expand Up @@ -300,6 +300,9 @@ export class Client extends ClientBase {

constructor(config?: string | ClientConfig);

connect(): Promise<Client>;
connect(callback: ((err: Error) => void) | ((err: null, c: Client) => void)): void;

end(): Promise<void>;
end(callback: (err: Error) => void): void;
}
Expand Down Expand Up @@ -342,8 +345,8 @@ import * as Pg from ".";
export const native: typeof Pg | null;

export { DatabaseError } from "pg-protocol";
import TypeOverrides = require("./lib/type-overrides");
export { TypeOverrides };
import TypeOverrides = require("./lib/type-overrides");

export class Result<R extends QueryResultRow = any> implements QueryResult<R> {
command: string;
Expand Down
2 changes: 1 addition & 1 deletion types/pg/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@types/pg",
"version": "8.16.9999",
"version": "8.18.9999",
"projects": [
"https://github.com/brianc/node-postgres"
],
Expand Down
8 changes: 4 additions & 4 deletions types/pg/pg-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ const escapeIdentifier: (str: string) => string = pg.escapeIdentifier;
const escapeLiteral: (str: string) => string = pg.escapeLiteral;

client.on("notice", (notice: NoticeMessage) => console.warn(`${notice.severity}: ${notice.message}`));
client.connect(err => {
client.connect((err, c) => {
if (err) {
console.error("Could not connect to postgres", err);
return;
}
client.query("SELECT NOW() AS 'theTime'", (err, result) => {
c.query("SELECT NOW() AS 'theTime'", (err, result) => {
if (err) {
console.error("Error running query", err);
return;
}
console.log(result.rowCount);
console.log(result.rows[0]["theTime"]);
client.end();
c.end();
return null;
});
return null;
Expand All @@ -68,7 +68,7 @@ client.on("end", () => console.log("Client was disconnected."));

client
.connect()
.then(() => console.log("connected"))
.then((c) => console.log("connected"))
.catch(e => console.error("connection error", e.stack));

client.query("SELECT NOW()", (err, res) => {
Expand Down