I have status collection and I have bellow Spring Data MongoDB query:
Query query = new Query(Criteria.where("reviewed").is(false)
            .and("active").is(true)
            .orOperator(
                Criteria.where("status").is("pending"),
                Criteria.where("status").is("inprogress")
                    .and("time").lt(new Date())
            )
        );
Now existing documents inside status collection might not have active, status, time fields, in this case query will return 0 results. I want to make them optional. If they are present they will be part of executing query otherwise they must be ignored.
After some research, I have come up with the below query:
Query query = new Query(Criteria.where("reviewed").is(false)
            .and("active").in(true, null)
            .orOperator(
                Criteria.where("status").in("pending", null),
                Criteria.where("status").in("inprogress", null)
                    .and("time").lt(new Date())
            )
        );
Is this the correct approach to achieve what I want or any suggestions please?
