neumino / rethinkdbdash

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

Conditional Chaining? #303

Closed chrisabrams closed 8 years ago

chrisabrams commented 8 years ago

I'm trying to write a query like this:

const done = true

let query = r.table('games').getAll(r.args['chess', 'checkers'], {index: 'type'})

if(done) {
  query.filter({
    status: 'done'
  })
}

const res = await query.run()

However, the filter part of the query is not executed. If I console.log query, it doesn't have the filter part. Is is possible to conditionally chain extra pieces of the query?

chrisabrams commented 8 years ago

Disregard. I need to take a break for the day :O