Skip to main content

Class: PGClient

postgres.PGClient PGClient is a client for Postgres database. Internally client uses go-pg/pg driver. Example

Table of contents

Constructors

Methods

Constructors

constructor

new PGClient(): PGClient

Returns

PGClient

Defined in

postgres.ts:16

Methods

Connect

Connect(host, port, username): boolean Connect connects to Postgres database using given credentials. If connection is successful, it returns true. If connection is unsuccessful, it returns false and error. The connection is closed after the function returns.

Parameters

Returns

boolean Example

Defined in

postgres.ts:44

ConnectWithDB

ConnectWithDB(host, port, username): boolean ConnectWithDB connects to Postgres database using given credentials and database name. If connection is successful, it returns true. If connection is unsuccessful, it returns false and error. The connection is closed after the function returns.

Parameters

Returns

boolean Example

Defined in

postgres.ts:78

ExecuteQuery

ExecuteQuery(host, port, username): SQLResult ExecuteQuery connects to Postgres database using given credentials and database name. and executes a query on the db. If connection is successful, it returns the result of the query.

Parameters

Returns

SQLResult Example

Defined in

postgres.ts:61

IsPostgres

IsPostgres(host, port): boolean IsPostgres checks if the given host and port are running Postgres database. If connection is successful, it returns true. If connection is unsuccessful, it returns false and error.

Parameters

Returns

boolean Example

Defined in

postgres.ts:27