neumino / rethinkdbdash

An advanced Node.js driver for RethinkDB with a connection pool, support for streams etc.
MIT License
848 stars 109 forks source link

Safe to reuse table terms? #390

Closed ghost closed 5 years ago

ghost commented 5 years ago

Is it safe to reuse a table term? e.g.

const myTable = r.db('abc').table('xyz');

function doQuery1() { return myTable.getAll(1, 2, 3); }
function doQuery2() { return myTable.filter({ x: 'y' }).limit(10); }
...

Or, should I force each query to create a new table term each time? e.g.

function doQuery1() { return r.db('abc').table('xyz').getAll(1, 2, 3); }
function doQuery2() { return r.db('abc').table('xyz').filter({ x: 'y' }).limit(10); }
ghost commented 5 years ago

I think the answer is NO, it is not safe to reuse a table term because in the code I see term._query being modified when any query function is called.