postgres.PGClient
PGClient is a client for Postgres database. Internally client uses go-pg/pg driver.
Example
• new PGClient(): PGClient
postgres.ts:16
▸ 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.
Name | Type |
---|---|
host | string |
port | number |
username | string |
boolean
Example
postgres.ts:44
▸ 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.
Name | Type |
---|---|
host | string |
port | number |
username | string |
boolean
Example
postgres.ts:78
▸ 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.
Name | Type |
---|---|
host | string |
port | number |
username | string |
Example
postgres.ts:61
▸ 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.
Name | Type |
---|---|
host | string |
port | number |
boolean
Example
postgres.ts:27
postgres.PGClient
PGClient is a client for Postgres database. Internally client uses go-pg/pg driver.
Example
• new PGClient(): PGClient
postgres.ts:16
▸ 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.
Name | Type |
---|---|
host | string |
port | number |
username | string |
boolean
Example
postgres.ts:44
▸ 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.
Name | Type |
---|---|
host | string |
port | number |
username | string |
boolean
Example
postgres.ts:78
▸ 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.
Name | Type |
---|---|
host | string |
port | number |
username | string |
Example
postgres.ts:61
▸ 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.
Name | Type |
---|---|
host | string |
port | number |
boolean
Example
postgres.ts:27