实际文件:
Document{{ID=7, NAME=trrrrr, amount=700}}
Document{{ID=6, NAME=kjjdj, amount=100}}
Document{{ID=5, NAME=dgsdg, amount=500}}
Document{{ID=2, NAME=fdfd, amount=200}}
Document{{ID=1, NAME=cggggg, amount=600}}
Document{{ID=3, NAME=kjhfjh, amount=300}}
下面是代码:
MongoDatabase db = mongoClient.getDatabase("db");
MongoCollection<Document> collection = db.getCollection("test");
BsonField id = Accumulators.first("ID", "$ID");
BsonField amount = Accumulators.first("amount", "$amount");
Bson group = Aggregates.group("$NAME",ID,NAME,amount);
现在我如何通过NAME和ID&lt; = 5
获取文档组