spring-data-mongo aggregate结果大于16m时处理方法

来源:互联网 发布:js怎么设置left值 编辑:程序博客网 时间:2024/06/05 22:52

spring-data-mongo aggregate结果大于16m时

可以使用游标(指针)方式返回结果 

 


    public List<DBObject> aggregateCURSOR(List<DBObject> pipeline) {

List<DBObject> list = new ArrayList<DBObject>();

Cursor output=MongoTemplate.getCollection("collectionName").aggregate(pipeline,

AggregationOptions.builder().outputMode(AggregationOptions.OutputMode.CURSOR).build());

while (output.hasNext()) {
DBObject obj=output.next();
list.add(obj);
        }

return  list;

   }

0 0
原创粉丝点击