List of usage examples for com.mongodb.client AggregateIterable useCursor
@Deprecated AggregateIterable<TResult> useCursor(@Nullable Boolean useCursor);
From source file:org.codinjutsu.tools.nosql.mongo.logic.SingleMongoClient.java
License:Apache License
private MongoResult aggregate(MongoQueryOptions mongoQueryOptions, MongoResult mongoResult, MongoCollection<Document> collection) { AggregateIterable<Document> aggregate = collection.aggregate(mongoQueryOptions.getOperations()); aggregate.useCursor(true); int index = 0; MongoCursor<Document> iterator = aggregate.iterator(); while (iterator.hasNext() && index < mongoQueryOptions.getResultLimit()) { mongoResult.add(iterator.next()); }/*from w ww. j ava 2s.c o m*/ return mongoResult; }