BasicDBObject的$sorts升序和降序如何设置?
解决方法:
1表示升序,-1表示降序
List<BasicDBObject> list=new ArrayList<BasicDBObject>();
DBObject sortFields = new BasicDBObject("sendtimesec",1);
BasicDBObject sort = new BasicDBObject("$sort", sortFields);
list.add(sort);
AggregateIterable<Document> aggregate = collection.aggregate(list);
本文链接:http://www.yayihouse.com/yayishuwu/chapter/1496