spring-data-mongodb
spring-data-mongodb copied to clipboard
Add support for $expr to Criteria query. [DATAMONGO-1845]
Christoph Strobl opened DATAMONGO-1845 and commented
Allow usage of Aggregation expressions in filter queries using $expr
.
db.monthlyBudget.find( { $expr: { $gt: [ "$spent" , "$budget" ] } } )
Reference URL: https://docs.mongodb.com/manual/reference/operator/query/expr/
3 votes, 3 watchers
What about adding an exprOperator
method to Criteria
that accepts an AggregationExpression
and behave like orOperator
and andOperator
? It allows to reuse all the aggregation operators already defined in spring-data-mongodb.
public Criteria exprOperator(AggregationExpression expression)
The example above could be written like this:
Criteria criteria = new Criteria()
.exprOperator(
ComparisonOperators.Gt
.valueOf("spent")
.greaterThan("budget")
);
opened over 4 years ago...would be good to get this.