Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
projectdiscovery
GitHub Repository: projectdiscovery/nuclei
Path: blob/dev/pkg/js/generated/ts/postgres.ts
2070 views
1
2
3
/**
4
* PGClient is a client for Postgres database.
5
* Internally client uses go-pg/pg driver.
6
* @example
7
* ```javascript
8
* const postgres = require('nuclei/postgres');
9
* const client = new postgres.PGClient;
10
* ```
11
*/
12
export class PGClient {
13
14
15
// Constructor of PGClient
16
constructor() {}
17
/**
18
* IsPostgres checks if the given host and port are running Postgres database.
19
* If connection is successful, it returns true.
20
* If connection is unsuccessful, it returns false and error.
21
* @example
22
* ```javascript
23
* const postgres = require('nuclei/postgres');
24
* const isPostgres = postgres.IsPostgres('acme.com', 5432);
25
* ```
26
*/
27
public IsPostgres(host: string, port: number): boolean | null {
28
return null;
29
}
30
31
32
/**
33
* Connect connects to Postgres database using given credentials.
34
* If connection is successful, it returns true.
35
* If connection is unsuccessful, it returns false and error.
36
* The connection is closed after the function returns.
37
* @example
38
* ```javascript
39
* const postgres = require('nuclei/postgres');
40
* const client = new postgres.PGClient;
41
* const connected = client.Connect('acme.com', 5432, 'username', 'password');
42
* ```
43
*/
44
public Connect(host: string, port: number, username: string): boolean | null {
45
return null;
46
}
47
48
49
/**
50
* ExecuteQuery connects to Postgres database using given credentials and database name.
51
* and executes a query on the db.
52
* If connection is successful, it returns the result of the query.
53
* @example
54
* ```javascript
55
* const postgres = require('nuclei/postgres');
56
* const client = new postgres.PGClient;
57
* const result = client.ExecuteQuery('acme.com', 5432, 'username', 'password', 'dbname', 'select * from users');
58
* log(to_json(result));
59
* ```
60
*/
61
public ExecuteQuery(host: string, port: number, username: string): SQLResult | null | null {
62
return null;
63
}
64
65
66
/**
67
* ConnectWithDB connects to Postgres database using given credentials and database name.
68
* If connection is successful, it returns true.
69
* If connection is unsuccessful, it returns false and error.
70
* The connection is closed after the function returns.
71
* @example
72
* ```javascript
73
* const postgres = require('nuclei/postgres');
74
* const client = new postgres.PGClient;
75
* const connected = client.ConnectWithDB('acme.com', 5432, 'username', 'password', 'dbname');
76
* ```
77
*/
78
public ConnectWithDB(host: string, port: number, username: string): boolean | null {
79
return null;
80
}
81
82
83
}
84
85
86
87
/**
88
* SQLResult Interface
89
*/
90
export interface SQLResult {
91
92
Count?: number,
93
94
Columns?: string[],
95
}
96
97
98