|
29 | 29 | import jakarta.nosql.document.DocumentEntity; |
30 | 30 | import jakarta.nosql.document.DocumentQuery; |
31 | 31 | import org.bson.BsonDocument; |
| 32 | +import org.bson.BsonValue; |
32 | 33 | import org.bson.Document; |
33 | 34 | import org.bson.conversions.Bson; |
34 | 35 | import org.eclipse.jnosql.communication.document.Documents; |
35 | 36 |
|
36 | 37 | import java.time.Duration; |
37 | 38 | import java.util.Collections; |
| 39 | +import java.util.HashMap; |
38 | 40 | import java.util.List; |
39 | 41 | import java.util.Map; |
40 | 42 | import java.util.Objects; |
@@ -187,16 +189,12 @@ public long delete(String collectionName, Bson filter) { |
187 | 189 | * @return the number of documents deleted. |
188 | 190 | * @throws NullPointerException when filter or collectionName is null |
189 | 191 | */ |
190 | | - public Map<String, Object> aggregate(String collectionName, List<Bson> pipeline) { |
| 192 | + public Stream<List<jakarta.nosql.document.Document>> aggregate(String collectionName, List<Bson> pipeline) { |
191 | 193 | Objects.requireNonNull(pipeline, "filter is required"); |
192 | 194 | Objects.requireNonNull(collectionName, "collectionName is required"); |
193 | 195 | MongoCollection<Document> collection = mongoDatabase.getCollection(collectionName); |
194 | 196 | AggregateIterable<Document> aggregate = collection.aggregate(pipeline); |
195 | | - for (Document document : aggregate) { |
196 | | - BsonDocument bson = document.toBsonDocument(); |
197 | | - System.out.println(bson); |
198 | | - } |
199 | | - return Collections.emptyMap(); |
| 197 | + return stream(aggregate.spliterator(), false).map(MongoDBUtils::of); |
200 | 198 | } |
201 | 199 |
|
202 | 200 | /** |
|
0 commit comments