I have an array whose contain some ID :
["4007fa1c-4e27-4d2e-9429-f3631171760c",
"a21649a3-1a64-45cf-b92a-e899a7ef4742",
"1903a571-b166-4f93-9c1c-93dc66067a49",
"2845d278-5ec4-45e9-ab9c-999178332c73",
"4e3ed481-a3d9-4689-8873-5c912668b26f",
"390e89fd-d680-4264-8806-8295b361d2f1"]
I would like thanks to this array, find all the posts having for "OriginID", one of the Ids present in the table.
I've started something like that, but I don't know how to complete to make work this code.
curs, _ = r.Table("posts").
Filter(r.Row.Field("Validated").Eq(false)).
Filter(func(customer r.Term) interface{}{
for _, id := range listOriginID {
//I don't know how to finish
}
})
Thank you for your help
When you find yourself trying to iterate over an array inside a ReQL query, it is often easier or necessary to use built-in ReQL operations such as Map
or ConcatMap
.
In this case, Contains
seems to be the operation you want. Try something like:
(...).Filter(func(post r.Term) interface{}{
r.Expr(listOriginID).Contains(post.Field("OriginID"))
})