1- use bson:: { doc, DateTime } ;
1+ use bson:: { doc, DateTime , Document } ;
22use mongodb:: { Client , Collection } ;
33use serde:: { Deserialize , Serialize } ;
4+ use futures:: stream:: TryStreamExt ;
45
56#[ tokio:: main]
67async 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