const r = require("rethinkdb");
r.connect({host: 'localhost', port: 28015}, (conn) => console.log(conn))
// Or as a promise
let rdb_conn;
r.connect({host: 'localhost', port: 28015}).then((conn) => {
rdb_conn = conn;
}).then(() => {
// Continue to use rdb_conn
});