2

Using the driver rethinkdbdash...

Given:

const rConnection = r.db('someDb').table('someTable')

How do I get the database name or the table name this connection is using from the variable rConnection?

Mike Fielden
  • 10,055
  • 14
  • 59
  • 99

1 Answers1

0

Similar to my answer here, here's an ugly solution that works (tested on rethinkdb, not rethinkdbdash):

nesh> let mom = (q, fn) => q.toString().match(new RegExp(fn + '\\(\\"(.*?)\\"\\)'))[1]
undefined
nesh> rql = r.db('foo').table('bar')
nesh> mom(rql, 'db')
'foo'
nesh> mom(rql, 'table')
'bar'
Community
  • 1
  • 1
Kludge
  • 2,653
  • 4
  • 20
  • 42