Skip to content

Commit 0af0d9f

Browse files
committed
code formatting
1 parent 8403eda commit 0af0d9f

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

source/includes/fundamentals/code-snippets/BulkWrite.java

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ private void insertExceptionExample() {
7878
try {
7979
List<WriteModel<Document>> bulkOperations = new ArrayList<>();
8080

81-
InsertOneModel<Document> doc3 = new InsertOneModel<>(new Document("_id", 1));
82-
InsertOneModel<Document> doc4 = new InsertOneModel<>(new Document("_id", 3));
81+
InsertOneModel<Document> doc1 = new InsertOneModel<>(new Document("_id", 1));
82+
InsertOneModel<Document> doc3 = new InsertOneModel<>(new Document("_id", 3));
8383

84+
bulkOperations.add(doc1);
8485
bulkOperations.add(doc3);
85-
bulkOperations.add(doc4);
8686

8787
collection.bulkWrite(bulkOperations);
8888

@@ -96,10 +96,14 @@ private void bulkWriteNotOrderedExample() {
9696
List<WriteModel<Document>> bulkOperations = new ArrayList<>();
9797

9898

99-
InsertOneModel<Document> insertDoc = new InsertOneModel<>(new Document("_id", 6).append("name", "Zaynab Omar").append("age", 37));
99+
InsertOneModel<Document> insertDoc = new InsertOneModel<>(new Document("_id", 6)
100+
.append("name", "Zaynab Omar")
101+
.append("age", 37));
100102
ReplaceOneModel<Document> replaceDoc = new ReplaceOneModel<>(Filters.eq("_id", 1),
101-
new Document("name", "Sandy Kane").append("location", "Helena, MT"));
102-
UpdateOneModel<Document> updateDoc = new UpdateOneModel<>(Filters.eq("name", "Zaynab Omar"), Updates.set("name", "Zaynab Hassan"));
103+
new Document("name", "Sandy Kane")
104+
.append("location", "Helena, MT"));
105+
UpdateOneModel<Document> updateDoc = new UpdateOneModel<>(Filters.eq("name", "Zaynab Omar"),
106+
Updates.set("name", "Zaynab Hassan"));
103107
DeleteManyModel<Document> deleteDoc = new DeleteManyModel<>(Filters.gt("age", 50));
104108

105109
bulkOperations.add(insertDoc);
@@ -121,10 +125,14 @@ private void bulkWriteExample() {
121125
List<WriteModel<Document>> bulkOperations = new ArrayList<>();
122126

123127

124-
InsertOneModel<Document> insertDoc = new InsertOneModel<>(new Document("_id", 6).append("name", "Zaynab Omar").append("age", 37));
128+
InsertOneModel<Document> insertDoc = new InsertOneModel<>(new Document("_id", 6)
129+
.append("name", "Zaynab Omar")
130+
.append("age", 37));
125131
ReplaceOneModel<Document> replaceDoc = new ReplaceOneModel<>(Filters.eq("_id", 1),
126-
new Document("name", "Sandy Kane").append("location", "Helena, MT"));
127-
UpdateOneModel<Document> updateDoc = new UpdateOneModel<>(Filters.eq("name", "Zaynab Omar"), Updates.set("name", "Zaynab Hassan"));
132+
new Document("name", "Sandy Kane")
133+
.append("location", "Helena, MT"));
134+
UpdateOneModel<Document> updateDoc = new UpdateOneModel<>(Filters.eq("name", "Zaynab Omar"),
135+
Updates.set("name", "Zaynab Hassan"));
128136
DeleteManyModel<Document> deleteDoc = new DeleteManyModel<>(Filters.gt("age", 50));
129137

130138
bulkOperations.add(insertDoc);
@@ -158,7 +166,8 @@ private void replaceDocumentsExample(){
158166
// begin replaceDocumentsExample
159167
ReplaceOneModel<Document> celineDoc = new ReplaceOneModel<>(
160168
Filters.eq("_id", 1),
161-
new Document("name", "Celine Stork").append("location", "San Diego, CA"));
169+
new Document("name", "Celine Stork")
170+
.append("location", "San Diego, CA"));
162171
//end replaceDocumentsExample
163172

164173
bulkOperations.add(celineDoc);
@@ -203,9 +212,15 @@ private void setUpCollection(){
203212
List<WriteModel<Document>> bulkOperations = new ArrayList<>();
204213
//end bulkOpsList
205214

206-
InsertOneModel<Document> karen = new InsertOneModel<>(new Document("_id", 1).append("name", "Karen Sandoval").append("age", 31));
207-
InsertOneModel<Document> william = new InsertOneModel<>(new Document("_id", 2).append("name", "William Chin").append("age", 54));
208-
InsertOneModel<Document> shayla = new InsertOneModel<>(new Document("_id", 8).append("name", "Shayla Ray").append("age", 20));
215+
InsertOneModel<Document> karen = new InsertOneModel<>(new Document("_id", 1)
216+
.append("name", "Karen Sandoval")
217+
.append("age", 31));
218+
InsertOneModel<Document> william = new InsertOneModel<>(new Document("_id", 2)
219+
.append("name", "William Chin")
220+
.append("age", 54));
221+
InsertOneModel<Document> shayla = new InsertOneModel<>(new Document("_id", 8)
222+
.append("name", "Shayla Ray")
223+
.append("age", 20));
209224

210225
bulkOperations.add(karen);
211226
bulkOperations.add(william);

0 commit comments

Comments
 (0)