From e23f62a8af6464ba7afb2f1dd09ec149813f3947 Mon Sep 17 00:00:00 2001 From: Stephanie Aurelio Date: Wed, 30 Oct 2024 14:10:10 -0700 Subject: [PATCH] update code examples --- .../fundamentals/code-snippets/aggregation.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/source/includes/fundamentals/code-snippets/aggregation.rs b/source/includes/fundamentals/code-snippets/aggregation.rs index 16d898a5..f043181f 100644 --- a/source/includes/fundamentals/code-snippets/aggregation.rs +++ b/source/includes/fundamentals/code-snippets/aggregation.rs @@ -1,6 +1,7 @@ -use bson::{ doc, DateTime }; +use bson::{ doc, DateTime, Document }; use mongodb::{ Client, Collection }; use serde::{ Deserialize, Serialize }; +use futures::stream::TryStreamExt; #[tokio::main] async fn main() -> mongodb::error::Result<()> { @@ -42,8 +43,7 @@ async fn main() -> mongodb::error::Result<()> { let mut results = my_coll.aggregate(age_pipeline).await?; while let Some(result) = results.try_next().await? { - let doc = mongodb::bson::from_document(result)?; - println!("* {:?}", doc); + println!("* {:?}", result); } // end-age-agg @@ -57,8 +57,7 @@ async fn main() -> mongodb::error::Result<()> { let mut results = my_coll.aggregate(last_active_pipeline).await?; while let Some(result) = results.try_next().await? { - let doc = mongodb::bson::from_document(result)?; - println!("* {:?}", doc); + println!("* {:?}", result); } // end-lastactive-agg @@ -72,8 +71,7 @@ async fn main() -> mongodb::error::Result<()> { let mut results = my_coll.aggregate(popularity_pipeline).await?; while let Some(result) = results.try_next().await? { - let doc = mongodb::bson::from_document(result)?; - println!("* {:?}", doc); + println!("* {:?}", result); } // end-popular-agg