0

Using RethinkDB's filter() function, given a field called field, how do we determine if field is an element of a set ['value1', 'value2'...'valueN'], and only filter rows where field is in such set?

One would be very pleased to see RethinkDB support Python's in operator, i.e.:

table.filter(r.row['field'] in ["value1", "value2", "valueN"])

But this is not supported.

The Aelfinn
  • 13,649
  • 2
  • 54
  • 45

1 Answers1

0

Using short-hand Python, and RethinkDB's or_ function, this can be accomplished with the following one-liner:

table.filter(r.or_(*tuple([r.row['field'] == val for val in values] )))
The Aelfinn
  • 13,649
  • 2
  • 54
  • 45