11use bson:: Document ;
2- use mongodb:: { bson:: doc, Client , Collection , options:: UpdateOptions } ;
2+ use mongodb:: { bson:: doc, options:: UpdateOptions , Client , Collection } ;
33use std:: env;
44
55#[ tokio:: main]
@@ -10,30 +10,31 @@ async fn main() -> mongodb::error::Result<()> {
1010 let my_coll: Collection < Document > = client. database ( "db" ) . collection ( "employees" ) ;
1111
1212 // begin-update
13- let update_doc =
14- doc ! {
13+ let update_doc = doc ! {
1514 "$set" : doc!{ "department" : "Business Operations" ,
1615 "role" : "Analytics Specialist" } ,
1716 "$inc" : doc!{ "bonus" : 500 }
1817 } ;
1918
20- let res = my_coll. update_many ( doc ! { "department" : "Marketing" } , update_doc, None ) . await ?;
19+ let res = my_coll
20+ . update_many ( doc ! { "department" : "Marketing" } , update_doc, None )
21+ . await ?;
2122 println ! ( "Modified {} document(s)" , res. modified_count) ;
2223 // end-update
2324
2425 // begin-replace
25- let replace_doc =
26- doc ! {
26+ let replace_doc = doc ! {
2727 "name" : "Susan Lee" ,
2828 "role" : "Lead Consultant" ,
2929 "team_members" : vec! [ "Jill Gillison" ]
3030 } ;
3131
32- let res = my_coll. replace_one ( doc ! { "_id" : 4501 } , replace_doc, None ) . await ?;
32+ let res = my_coll
33+ . replace_one ( doc ! { "_id" : 4501 } , replace_doc, None )
34+ . await ?;
3335 println ! (
3436 "Matched {} document(s)\n Modified {} document(s)" ,
35- res. matched_count,
36- res. modified_count
37+ res. matched_count, res. modified_count
3738 ) ;
3839 // end-replace
3940
0 commit comments