Closed Tryneus closed 7 years ago
So at risk of asking a stupid question, would the correct example be more like:
const express = require('express');
const horizon = require('@horizon/server');
const app = express();
const httpServer = app.listen(8181);
const options = {
project_name: 'myProject',
auth: { token_secret: 'my_super_secret_secret' }
};
const horizonServer = horizon(httpServer, options);
const conn = horizonServer._reql_conn.connection();
@chipotle - not entirely - the connection will not be ready immediately, so the ready()
function returns a promise:
...
const horizonServer = horizon(httpServer, options);
const r = horizon.r;
horizonServer._reql_conn.ready().then((reql_conn) => {
r.expr('foo').run(reql_conn.connection());
});
Also, the header for the section indicates it was to show how the same r
object can be used, I though the ReQL connection was just an aside.
Anyway, a lot of this stuff is changing for the plugins feature, though, so I wouldn't put too much work into this section yet.
in
docs/embed
, the last sectionAccessing the Rethinkdb 'r' object
has the code:This is wrong,
_reql_conn
is a property of aServer
instance, not of the@horizon/server
module. In order to get the connection, you need to instantiate aServer
and pass it the information forr.connect
, at which point it may become available.See related issue at rethinkdb/horizon#807