MMhr
MMhr

Reputation: 13

Couchbase java N1QL DSL query statement with IN expression

Trying to write a N1QL query like

SELECT * from bucket
WHERE s IN ["s1", "s2", ..., "sn"]
END;

in DSL. Assuming I have a list of Strings called s_array, I need to write something like this:

select("*").from("bucket")
.where(x("s").in(s_array);

Whats the best way to write the IN expression in DSL without concatenating all list elements in a String or something?

Upvotes: 1

Views: 162

Answers (1)

Graham Pople
Graham Pople

Reputation: 516

You can do this with the JsonArray overload, as so:

select("*").from("bucket")
            .where(x("s").in(JsonArray.from("s1", "s2", "s3"));

Upvotes: 1

Related Questions