Couchbase Lite 2.0 DISTINCT Operator In QueryBuilder

Hi, I’m using Couchbase Lite 2.0 for Android, and I’m trying to construct a query using the QueryBuilder object. However, I can’t figure out how to perform a SELECT DISTINCT query, as in:

Specifically, I’m trying to get the list of all “types” in my database, like so:

Query query ="type"))).from(DataSource.database(database));

query.addChangeListener(new QueryChangeListener()
        @Override public void changed(QueryChange change)
            ResultSet resultSet = change.getResults();

            for(Result result : resultSet)
                String type = result.getString(0);



but I want to avoid duplicates. Does Couchbase Lite’s QueryBuilder have the ability to filter out duplicates using a DISTINCT operator or something similar?

There is a selectDistinct that you can use…

 Query q = QueryBuilder.selectDistinct("type")).from(DataSource.database(db));
1 Like