spring-data-mongodb
spring-data-mongodb copied to clipboard
Add support for CriteriaDefinition on $or operator
Currently in Criteria
class we have the method
public Criteria orOperator(Criteria... criteria) {
BasicDBList bsonList = createCriteriaList(criteria);
return registerCriteriaChainElement(new Criteria("$or").is(bsonList));
}
This can be changed to
public Criteria orOperator(CriteriaDefinition... criteria) {
BasicDBList bsonList = createCriteriaList(criteria);
return registerCriteriaChainElement(new Criteria("$or").is(bsonList));
}
In this case it will be more flexible, and also it will be possible to have Criteria
and TextCriteria
mixed in $or operator.
I might be wrong, but I don't think this is ideal, Criteria being a concrete class if supports an interface type as parameter while returning a concrete instance of Criteria again means the relation of Criteria and TextCriteria is not sibling.
@christophstrobl do we want to do this change? Everywhere inside the Criteria class we use Criteria as a parameter. If we want to support CriteriaDefinition, we will allow to to use all implementations and mix the CriteriasDefinitions implementations. We would have to update all the methods, not just this one