File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -194,6 +194,8 @@ GROUP BY year;
194194 <TabItem value = " java" label = " Java" >
195195 <div >
196196 ``` java
197+ MongoCollection<Document > reviews = library. getCollection(" reviews" );
198+
197199 reviews. aggregate(
198200 List . of(
199201 Aggregates . group(" $bookId" ,
@@ -339,7 +341,9 @@ GROUP BY year;
339341 <div >
340342 ``` java
341343 import static com.mongodb.client.model.Sorts.descending ;
342-
344+
345+ MongoCollection<Document > reviews = library. getCollection(" reviews" );
346+
343347 reviews. aggregate(
344348 List . of(Aggregates . group(
345349 " $name" ,
@@ -353,6 +357,8 @@ GROUP BY year;
353357 <TabItem value = " $sortByCount" label = " $sortByCount" >
354358 <div >
355359 ``` java
360+ MongoCollection<Document > reviews = library. getCollection(" reviews" );
361+
356362 reviews. aggregate(
357363 List . of(
358364 Aggregates . sortByCount(" $name" ))
Original file line number Diff line number Diff line change @@ -170,6 +170,8 @@ The $lookup operation creates an array within each book document. Using $unwind
170170 ``` java
171171 import com.mongodb.client.model.Aggregates ;
172172
173+ MongoCollection<Document > books = library. getCollection(" books" );
174+
173175 books. aggregate(
174176 List . of(
175177 Aggregates . lookup(
You can’t perform that action at this time.
0 commit comments