Bạn có thể thử truy vấn bên dưới.
Nhập tĩnh
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;
Mã
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)