How to get database name from a connection?

119 views Asked by At

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?

1

There are 1 answers

0
Kludge On

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'