RethinkDB Unhandled Rejection No stack trace

372 views Asked by At

I'm using RethinkDB with Rethinkdbdash (node.js) and for a few days now Im getting this error:

Unhandled rejection (<[{"entries":3,"id":1357186,"item":{"co...>, no stack trace)

Doesn't matter what query do I run, when i try to get any info from the database I always get the same error. If nothing is returned, error looks like this:

Unhandled rejection (<(empty array)>, no stack trace)

This is my current code:


     r.table('example').run().then(function(err, result){
      if(err) throw err;
      console.log(result);
    })

1

There are 1 answers

0
SeqSEE On

You would need to include the database: 'databasename' field in the config object and pass the config object into run, otherwise you could try to specify the db in your ReQL query.

Specify db for connection:

let connection = null
r.connect( { host: 'localhost', port: 28015, user: 'user', password: 'password', database: 'databasename'}, function(err, conn) {
    if (err) throw err
    else {
      connection = conn
      r.table('example').run(connection, function(err, result){
        if(err) throw err;
        else console.log(`${JSON.stringify(result)}`);
      })
    }    
})

Specify db in query:

let connection = null
r.connect( { host: 'localhost', port: 28015, user: 'user', password: 'password'}, function(err, conn) {
    if (err) throw err
    else {
      connection = conn
      r.db('databasename').table('example').run(connection, function(err, result){
        if(err) throw err;
        else console.log(`${JSON.stringify(result)}`);
      })
    }    
})