spring-data-mongodb
spring-data-mongodb copied to clipboard
Add a generic PropertyExpression for AggregationExpression
Add a generic PropertyExpression to give an alias for any AggregationExpression currently you can use a class in ArrayOperators.Reduce.PropertyExpression which is i think misleading as i first thought it will be only used in related to ArrayOperators.Reduce
Let's take a step back before trying to fix an issue and elaborate on what you want to achieve.
@mp911de for the following mongodb stage
{
$addFields: {
orders:{
$map: {
input: "$orders",
as: "order",
in: {
$mergeObjects: [
"$$order",
{
**instance:** {
$first: {
$filter: {
input: "$instances",
as: "instance",
cond: {
$eq: [ "$$order.instance.docKey", "$$instance._id",
],
},
},
}
},
},
],
},
},
},
}
}
to give alias (instance) for result of $first(aggregate expression) i have used ```
ArrayOperators.Reduce.PropertyExpression.property("instance")
.definedAs(aggregateExpression)
so what i said is PropertyExpression should be in separate class instead of in ArrayOperators.Reduce