Get documents that are not RED or GREEN not working with query builder

I have documents like {status: ‘RED’}, {status:‘GREEN’}, {status:‘YELLOW’}…

Now I want to get all documents that re not RED or GREEN. The query below works well with vs code Couchbase Lite extension:

select meta().id, status from _ WHERE (status != "RED" AND status != "GREEN")

but it is not working in query builder with expression:

      Expression.property(
                   "status"
                ).notEqualTo(Expression.string("RED").and(Expression.string("GREEN"))

I don’t know anything about query builder - but to get the equivalent logic, wouldn’t it be:

Expression.property("status").notEqualTo(Expression.string("RED")).and(Expression.property("status").notEqualTo(Expression.string("GREEN")

2 Likes

Beat me to it. What you’ve written in QueryBuilder is essentially WHERE status != "RED" AND "GREEN"