Możesz spróbować poniżej zapytania.
Importy statyczne
import static org.springframework.data.mongodb.core.aggregation.Aggregation.*;
import static org.springframework.data.mongodb.core.aggregation.ArrayOperators.Filter.filter;
import static org.springframework.data.mongodb.core.aggregation.ComparisonOperators.Eq.valueOf;
Kod
Aggregation aggregation = newAggregation(
project().and(filter("parts")
.as("item")
.by(valueOf(
"item.currentState")
.equalToValue(
"Estimation Confirmed")))
.as("parts");
);
List<outputType> results = mongoTemplate.aggregate(aggregation, inputType, outputType)