You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DATAMONGO-861 - Add support for $cond and $ifNull operators in aggregation operations.
We now support $cond and $ifNull operators for projection and grouping operations. ConditionalOperator and IfNullOperators are AggregationExpressions that can be applied to transform or generate values during aggregation.
TypedAggregation<InventoryItem> agg = newAggregation(InventoryItem.class,
project().and("discount")
.transform(ConditionalOperator.newBuilder().when(Criteria.where("qty").gte(250))
.then(30)
.otherwise(20))
.and(ifNull("description", "Unspecified")).as("description")
);
corresponds to
{ "$project": { "discount": { "$cond": { "if": { "$gte": [ "$qty", 250 ] },
"then": 30, "else": 20 } },
"description": { "$ifNull": [ "$description", "Unspecified"] }
}
}
Original Pull Request: #385
0 commit comments