-
Notifications
You must be signed in to change notification settings - Fork 217
/
connection.ts
60 lines (49 loc) · 1.06 KB
/
connection.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import * as pgPromise from '../../typescript/pg-promise';
import {IConnectionParameters} from '../../typescript/pg-subset';
const pgp: pgPromise.IMain = pgPromise({
schema: ['public', 'mine'],
capSQL: true,
noLocking: true,
pgNative: true,
pgFormatting: true,
noWarnings: true
});
const pgp2: pgPromise.IMain = pgPromise({
schema: () => {
}
});
const pgp3: pgPromise.IMain = pgPromise({
schema: (dc: any) => {
return ['one', 'two'];
}
});
const db = pgp('connection');
type t = IConnectionParameters;
let r: t;
r.application_name = 'hello';
r.ssl = {
ca: ''
};
r.password = () => 'pass123';
r.keepAlive = true;
const db2 = pgp({
binary: true
});
db.connect()
.then(ctx => {
ctx.batch([1, 2, 3]);
ctx.sequence(index => {
});
ctx.page(a => {
});
const cn = ctx.client.connectionParameters;
ctx.done();
});
db.connect({});
db.connect({
direct: true,
onLost: (err, e) => {
e.client.removeListener('notification', () => {
})
}
});