.netfilterrethinkdbreql

How to filter a Table based on appartenance to a list


I am trying to filter a table , the predicate being the appartenance to a list in Code. Can this be done from code and without needing the list to be added in a RethinkDB table?

var list=new List<int>{1,2,3};
var filter=r.Db("someDb").Table("SomeTable").Filter(x=>list.Contains(x("field")));

As you can see i have the list in c# but i cannot somehow put it as a predicate in Reql syntax.Is there anyway to do this?

Or can i somehow create an expression using a for like var basicExpression;

foreach(var item in list)
{
  basicExpression.Or(x("something").Eq(item));
}

And at the end make one big expression ?


Solution

  • In the javascript driver it is supposed to be like this:

    r.db("someDb").table('SomeTable').filter(function (x) {
        return r.expr(['1', '2', '3']).contains(x('field'))
    })
    

    However, in the .net driver i am not sure, maybe:

    var filter = r.Db("someDb").Table("SomeTable")
            .Filter(x => R.Expr(new[]{'1','2','3'}).Contains(x("field")));