MongoDB
 sql >> Database >  >> NoSQL >> MongoDB

Crea un'aggregazione di filtri in primavera

Puoi provare sotto la query.

Importazioni statiche

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;

Codice

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)