RethinkDB: IN List example

RethinkDB has an interesting syntax for doing IN lists, where the IN list comes before the column:

r.db('test')
 .table('users')
 .filter( 
    (doc) => 
      r.expr(['test', 'sieling'])
       .contains(doc('last_name')
 ) 
)
first_name
id
last_name
user_name
1
gary
903e0943-8ffe-41ca-a22f-7b1a964b399d
sieling
gsieling
2
gary
479e9ce1-e0bb-46b3-a65f-554ac237460a
sieling
gsieling
3
test
1b223750-799d-402a-b378-74c993a9c10c
test
test
4
gary
947a3ce6-d419-4d31-bd1e-874c721a9e6c
sieling
gsieling

One nice thing about this is that there doesn’t seem to be a length limit – in Oracle, IN lists are arbitrarily capped at 1,000 entries.

In testing this, I did find that at some point the RethinkDB UI gets harder to use and may crash the browser. But it seems to retain it’s memory of what you had in your query, so it recovers much more easily than older tools

Leave a Reply

Your email address will not be published. Required fields are marked *