RethinkDB chaining/combining filters

633 views Asked by At

I have two filters that I need to combine.

This is my primary filter:

r.db('items').table('tokens').filter(r.row('valid_to').gt(r.now()))

and this is my secondary filter.

.filter(r.row["processed"] == False)

How do I combine these?

2

There are 2 answers

0
Jorge Silva On BEST ANSWER

Just chain them together!

r.db('items').table('tokens')
 .filter(r.row('valid_to').gt(r.now()))
 .filter(r.row["processed"] == False)

And you can keep chaining stuff after that.

0
AGradePHP On

Once you have the database set, you can use the filters to carry on your equation, such as:

 $query = \r\table('payments')
->filter(\r\row('forwarded')->eq('1'))
->filter(\r\row('bad_callbacks_sent')->lt(6))
->filter(\r\row('confirmations')->le(7))
->run($this->conn);

You see I have the table set, which means I can continue doing queries for that table without re-defining that table.