为什么 Contains in .Filter(func()) 在 gorethink 中不起作用并且部分查询被忽略?

Why Contains in .Filter(func()) is not working in gorethink and parts of query get ignored?

我正在尝试这样做:

r.table(table).filter(
  function (doc) {
    return r.expr(array)
            .contains(doc("name"));
  }
)

用golang写的就是

rethink.Table(table).GetAllByIndex(index, value).Filter(func(row rethink.Term) interface {}{

    return rethink.Expr([]string{}).Contains(row.Field("type"))
})

我不确定,但好像 rethink.Expr 被忽略了。 这是第一个问题。

接下来是第二个问题。如果我有这样写的查询:

query := rethink.Table(table).GetAllByIndex(index, value)

然后尝试下一步:

if some_condition {
   q.Filter(some_filter)
}

if some_other_condition {
   q.Filter(some_other_filter)
}

当我打印出来时 q.String() 我只得到了第一部分,其他的都被忽略了 rethink.Table(table).GetAllByIndex(index, value)

由于Filter method returns a new Term中会包含前一项的表达式,需要重新计算结果返回q

if some_condition {
   q = q.Filter(some_filter)
}

if some_other_condition {
   q = q.Filter(some_other_filter)
}