0

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);
    })

NilmeX
  • 63
  • 1
  • 6
  • maybe you want to post your full code, with connection initialization and so. – taygetos Jan 10 '19 at 11:31
  • There is no connection initialization. As I mentioned, I use RethinkDBDash, so the only code is ```const r = require('rethinkdbdash')(config.db);``` – NilmeX Jan 10 '19 at 14:53
  • I also want to mention that inserting and pulling works, but it returns this as a response. – NilmeX Jan 10 '19 at 14:54
  • i am not particularly familiar with RethinkDBdash, but isn't this how it supposed to work? : r.table('example').run().then(function(result){ console.log(result); }).catch(err){ console.log(err); } – taygetos Jan 10 '19 at 15:05
  • Unfortunately that doesn't help my case – NilmeX Jan 10 '19 at 15:21

1 Answers1

0

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)}`);
      })
    }    
})
SeqSEE
  • 94
  • 8