如何運行具有匹配和投影的聚合。投影包括一個字段并排除 id。db.collection("Collection").aggregate([ { $match : { "someCriteriaFlag" : false } }, { $project : { "field1" : 1, "_id" : 0 } }]);在爪哇Aggregation aggregation = Aggregation.newAggregation( Aggregation.match(Criteria.where("someCriteriaFlag").is(false)), Aggregation.project("field1"));List<String> fields= mongoTemplate.aggregate(aggregation, "Collection", BasicDBObject.class) .getMappedResults();
mong模板聚合匹配和投影一個字段,沒有id
慕桂英4014372
2022-09-21 17:29:40