Skip to content

Commit 16d2e03

Browse files
authored
Merge pull request #227 from redmitry/patch-1
optimize aggregate()
2 parents 6190f70 + 87c76e1 commit 16d2e03

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

jnosql-mongodb/src/main/java/org/eclipse/jnosql/databases/mongodb/communication/MongoDBDocumentManager.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,9 @@ public long delete(String collectionName, Bson filter) {
208208
public Stream<Map<String, BsonValue>> aggregate(String collectionName, List<Bson> pipeline) {
209209
Objects.requireNonNull(pipeline, "filter is required");
210210
Objects.requireNonNull(collectionName, "collectionName is required");
211-
MongoCollection<Document> collection = mongoDatabase.getCollection(collectionName);
212-
AggregateIterable<Document> aggregate = collection.aggregate(pipeline);
213-
return stream(aggregate.spliterator(), false)
214-
.map(Document::toBsonDocument);
211+
MongoCollection<BsonDocument> collection = mongoDatabase.getCollection(collectionName, BsonDocument.class);
212+
AggregateIterable aggregate = collection.aggregate(pipeline);
213+
return stream(aggregate.spliterator(), false);
215214
}
216215

217216
/**

0 commit comments

Comments
 (0)