forked from ronzeidman/rebirthdbts
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathtest.ts
66 lines (60 loc) · 1.68 KB
/
test.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
61
62
63
64
65
66
import { r } from './src';
// export class Server {
// private pool!: MasterPool;
// public async connect() {
// const options = {
// host: 'localhost',
// port: 28015,
// db: 'catalog',
// silent: false,
// pingInterval: 1,
// waitForHealthy: false
// };
// // these are never called even though the server are taken down,
// // or not started at program start but are made available later...
// this.pool = await r.connectPool(options);
// this.pool.on('error', e => {
// console.log('error', e);
// });
// this.pool.on('size', e => {
// console.log('size', e);
// });
// this.pool.on('available-size', e => {
// console.log('available-size', e);
// });
// this.pool.on('healthy', e => {
// console.log('healthy', e);
// });
// }
// public check() {
// setInterval(async () => {
// // this will continue to print true, 1, 1 even if the server goes down...
// console.log(this.pool.isHealthy);
// console.log(this.pool.getAvailableLength());
// console.log(this.pool.getLength());
// const result = await r
// .table('PhoneCatalog')
// .filter({ callsign: 'xxx' })
// .run()
// .catch(what => console.log('catch', what));
// console.log(result);
// }, 1000 * 5);
// }
// }
// const s = new Server();
// s.connect();
// s.check();
r.connectPool({
host: '127.0.0.1',
port: 28015,
db: 'test',
silent: true
});
(async function getData() {
const pool = r.getPoolMaster();
if (pool) {
await pool.waitForHealthy();
}
const result = await r.table('test').run();
console.log(JSON.stringify(result));
})();