Skip to content

Commit a1a0c3d

Browse files
authored
DOCSP-30541: Change guide tech review (#47)
1 parent fa6f85f commit a1a0c3d

File tree

1 file changed

+10
-9
lines changed
  • source/includes/fundamentals/code-snippets/crud

1 file changed

+10
-9
lines changed

source/includes/fundamentals/code-snippets/crud/change.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use bson::Document;
2-
use mongodb::{ bson::doc, Client, Collection, options::UpdateOptions };
2+
use mongodb::{bson::doc, options::UpdateOptions, Client, Collection};
33
use 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)\nModified {} 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

Comments
 (0)