Search code examples
javascriptrethinkdbrethinkdb-javascript

How to query RethinkDB based on a list of IDs


Suppose I have the following table in RethinkDB:

enter image description here

I would like to query based on a list of IDs, for example the first two. It seems like the getAll function should do this, but I can't seem to get it to work:

enter image description here

The query returns no results, even though I copy-pasted the IDs from those shown on the previous screen grab. Is this not the correct way to use getAll?


Solution

  • You should use args for this:

    r.db("sensor_db).table("sensor_data").getAll(r.args([id1, id2]))
    

    or you can write query without []:

    r.db("sensor_db).table("sensor_data").getAll(id1, id2,...)