Skip to content

Commit 923eb86

Browse files
terakilobytestIncMale
authored andcommitted
print using lamda expression
1 parent f81cc87 commit 923eb86

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

docs/reference/content/driver/tutorials/aggregation.md

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,8 @@ The [aggregation pipeline]({{<docsref "core/aggregation-pipeline" >}}) is a fram
2828
import com.mongodb.client.model.Accumulators;
2929
import com.mongodb.client.model.Projections;
3030
import com.mongodb.client.model.Filters;
31-
32-
import org.bson.Document;
33-
```
34-
35-
- Include the following code which the examples in the tutorials will use to print the results of the aggregation:
3631

37-
```java
38-
Block<Document> printBlock = new Block<Document>() {
39-
@Override
40-
public void apply(final Document document) {
41-
System.out.println(document.toJson());
42-
}
43-
};
32+
import org.bson.Document;
4433
```
4534

4635
## Connect to a MongoDB Deployment
@@ -73,7 +62,7 @@ collection.aggregate(
7362
Aggregates.match(Filters.eq("categories", "Bakery")),
7463
Aggregates.group("$stars", Accumulators.sum("count", 1))
7564
)
76-
).forEach(printBlock);
65+
).forEach(doc -> System.out.println(doc.toJson()));
7766
```
7867

7968
### Use Aggregation Expressions
@@ -98,7 +87,7 @@ collection.aggregate(
9887
)
9988
)
10089
)
101-
).forEach(printBlock);
90+
).forEach(doc -> System.out.println(doc.toJson()));
10291
```
10392

10493
### Explain an Aggregation

0 commit comments

Comments
 (0)