Rethinkdb: how to call getAll with array of predefined ids

221 views Asked by At

Have some ids:

let uIds = ['2e56c685-977b-41df-95dd-6adab3aef009', 
  'dc636c8c-46b8-4022-bea8-a17e692e75ce'
  ];

How to get all records with these ids?

This doesn't work:

r.db('test').table('users').getAll(uIds)   

And this too:

r.db('test').table('users').getAll.apply(this, uIds)

And even this:

r.db('test').table('users').getAll(r.expr(uIds))
1

There are 1 answers

0
Etienne Laurin On BEST ANSWER

You can use r.args to splice arguments:

.getAll(r.args(uIds))

If those arguments are known when building the query, you can also use apply , but it must be called with the proper this argument:

var table = r.table('users');
table.getAll.apply(table, uIds)