Skip to content

Commit 02c4305

Browse files
committed
DOCSP-44862 Update aggregation code examples (#141)
(cherry picked from commit 179c64e)
1 parent 808721f commit 02c4305

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

source/includes/fundamentals/code-snippets/aggregation.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
use bson::{ doc, DateTime };
1+
use bson::{ doc, DateTime, Document };
22
use mongodb::{ Client, Collection };
33
use serde::{ Deserialize, Serialize };
4+
use futures::stream::TryStreamExt;
45

56
#[tokio::main]
67
async fn main() -> mongodb::error::Result<()> {
@@ -42,8 +43,7 @@ async fn main() -> mongodb::error::Result<()> {
4243

4344
let mut results = my_coll.aggregate(age_pipeline).await?;
4445
while let Some(result) = results.try_next().await? {
45-
let doc = mongodb::bson::from_document(result)?;
46-
println!("* {:?}", doc);
46+
println!("* {:?}", result);
4747
}
4848
// end-age-agg
4949

@@ -57,8 +57,7 @@ async fn main() -> mongodb::error::Result<()> {
5757

5858
let mut results = my_coll.aggregate(last_active_pipeline).await?;
5959
while let Some(result) = results.try_next().await? {
60-
let doc = mongodb::bson::from_document(result)?;
61-
println!("* {:?}", doc);
60+
println!("* {:?}", result);
6261
}
6362
// end-lastactive-agg
6463

@@ -72,8 +71,7 @@ async fn main() -> mongodb::error::Result<()> {
7271

7372
let mut results = my_coll.aggregate(popularity_pipeline).await?;
7473
while let Some(result) = results.try_next().await? {
75-
let doc = mongodb::bson::from_document(result)?;
76-
println!("* {:?}", doc);
74+
println!("* {:?}", result);
7775
}
7876
// end-popular-agg
7977

0 commit comments

Comments
 (0)