Use array or list with "in" expression


#1

Hi, does Couchbase Lite 2.0.2 for Android have any kind of support for passing in arrays or lists into the QueryBuilder’s in() method?

For example, in the following query I’m trying to get all documents of type ‘user’ where the ‘user_id’ is in a user provided list:

String[] userIds = new String[]{"54", "72", "83"};
            
Query query = QueryBuilder.select(SelectResult.all()).from(DataSource.database(database)).where(Expression.property("type").equalTo(Expression.string("user")).and(Expression.property("user_id").in(userIds)))

If there’s no support for this, is this the correct forum for me to make a feature request?


#2

Feature requests should be made by filing GitHub issues. The functionality you are after is not present as it requires passing a naked array value as an expression. Currently expressions are limited to numeric types, null, string, bool, and date.

Side note: the syntax you are using is questionable as I think you are after the contains method, not the in method (there is a writeup on collection querying here).