如何将mongodb查询转换为java
我想将以下查询转换为java
db.Student.aggregate( {$group : {_id : "$prnno", x: {$push:"$name"} , st:{$push: "$per"} }},
{$sort:{st:-1} },{$limit:3});
答案 0 :(得分:0)
尝试这个,我希望它有所帮助:
collection.aggregate(Arrays.asList({$or:[
new BasicDBObject("$match", new BasicDBObject("x", {$push:"$name"})),
new BasicDBObject("$match", new BasicDBObject("st", {$push: "$per"}))],
new BasicDBObject("$sort", new BasicDBObject("st", -1)),
new BasicDBObject("$limit", 3)))