RethinkDB: “Expected type SEQUENCE but found SINGLE_SELECTION”

If you write a query like this:

r.db('test')
 .table('users')
 .get('first_name')
 .filter(
     (x) => 
        r.db('test')
         .table('users')
         .pluck('id')
         .contains(x("id"))
   )

You can get an error like so:

e: Expected type SEQUENCE but found SINGLE_SELECTION:

This is attempting to filter one set of rows from another.

A simpler way to do this is to use a join:

r.db('test')
 .table('users')
 .eqJoin(
     'id',
     r.table('users')
   )

Leave a Reply

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