Given the table checkpointAttempts
, with schema:
{
id: primary_key,
userId: secondary_key & index,
checkpointId: secondary_key & index
}
I'm trying to find all of the checkpointAttempts
matching both an array of userIds
and an array of checkpointIds
at runtime.
I thought it might work by doing this:
// var userIds and checkpointIds are defined arrays & in scope
var q = r.table("checkpointAttempts");
q = q.getAll.apply(q, userIds.concat({index: userId}))
.filter(function(attempt){
return checkpointIds.indexOf(attempt('checkpointId')) !== -1
})
.run(conn)
But, filter
's predicate function seems to always return false.
Any suggestions as to what I'm doing wrong, or how I might construct this query differently?
Thanks!