Skip to content

Commit ef7890d

Browse files
committed
DJ feedback
1 parent 41a5855 commit ef7890d

File tree

2 files changed

+18
-21
lines changed

2 files changed

+18
-21
lines changed

source/code-snippets/crud/bulk.js

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ const {
66
const uri = '<connection string>'; // Add your MongoDB connection string here
77

88
(async () => {
9-
const client = new MongoClient(uri, {
10-
useNewUrlParser: true,
11-
useUnifiedTopology: true
12-
});
9+
const client = new MongoClient(uri);
1310

1411
try {
1512
await client.connect();
@@ -38,8 +35,8 @@ const uri = '<connection string>'; // Add your MongoDB connection string here
3835
}
3936
}];
4037

41-
const insert_result = await movies.bulkWrite(insertModels);
42-
console.log(`Inserted documents: ${insert_result.insertedCount}`);
38+
const insertResult = await movies.bulkWrite(insertModels);
39+
console.log(`Inserted documents: ${insertResult.insertedCount}`);
4340
// end-insert-coll
4441

4542
// begin-insert-client
@@ -70,8 +67,8 @@ const uri = '<connection string>'; // Add your MongoDB connection string here
7067
}
7168
}];
7269

73-
const client_insert_res = await client.bulkWrite(clientInserts);
74-
console.log(`Inserted documents: ${client_insert_res.insertedCount}`);
70+
const clientInsertRes = await client.bulkWrite(clientInserts);
71+
console.log(`Inserted documents: ${clientInsertRes.insertedCount}`);
7572
// end-insert-client
7673

7774
await movies.insertMany(docs);
@@ -103,8 +100,8 @@ const uri = '<connection string>'; // Add your MongoDB connection string here
103100
}
104101
}];
105102

106-
const replace_result = await movies.bulkWrite(replaceOperations);
107-
console.log(`Modified documents: ${replace_result.modifiedCount}`);
103+
const replaceResult = await movies.bulkWrite(replaceOperations);
104+
console.log(`Modified documents: ${replaceResult.modifiedCount}`);
108105
// end-replace-coll
109106

110107
// begin-replace-client
@@ -142,8 +139,8 @@ const uri = '<connection string>'; // Add your MongoDB connection string here
142139
}
143140
}];
144141

145-
const client_replace_res = await client.bulkWrite(clientReplacements);
146-
console.log(`Modified documents: ${client_replace_res.modifiedCount}`);
142+
const clientReplaceRes = await client.bulkWrite(clientReplacements);
143+
console.log(`Modified documents: ${clientReplaceRes.modifiedCount}`);
147144
// end-replace-client
148145

149146
// begin-update-coll
@@ -174,8 +171,8 @@ const uri = '<connection string>'; // Add your MongoDB connection string here
174171
}
175172
}];
176173

177-
const update_result = await movies.bulkWrite(updateOperations);
178-
console.log(`Modified documents: ${update_result.modifiedCount}`);
174+
const updateResult = await movies.bulkWrite(updateOperations);
175+
console.log(`Modified documents: ${updateResult.modifiedCount}`);
179176
// end-update-coll
180177

181178
// begin-update-client
@@ -206,8 +203,8 @@ const uri = '<connection string>'; // Add your MongoDB connection string here
206203
},
207204
upsert: false
208205
}];
209-
const client_update_res = await client.bulkWrite(clientUpdates);
210-
console.log(`Modified documents: ${client_update_res.modifiedCount}`);
206+
const clientUpdateRes = await client.bulkWrite(clientUpdates);
207+
console.log(`Modified documents: ${clientUpdateRes.modifiedCount}`);
211208
// end-update-client
212209

213210
// begin-delete-coll
@@ -225,8 +222,8 @@ const uri = '<connection string>'; // Add your MongoDB connection string here
225222
}
226223
}];
227224

228-
const delete_result = await movies.bulkWrite(deleteOperations);
229-
console.log(`Deleted documents: ${delete_result.deletedCount}`);
225+
const deleteResult = await movies.bulkWrite(deleteOperations);
226+
console.log(`Deleted documents: ${deleteResult.deletedCount}`);
230227
// end-delete-coll
231228

232229
// begin-delete-client
@@ -244,8 +241,8 @@ const uri = '<connection string>'; // Add your MongoDB connection string here
244241
}
245242
}];
246243

247-
const client_delete_res = await client.bulkWrite(clientDeletes);
248-
console.log(`Deleted documents: ${client_delete_res.deletedCount}`);
244+
const clientDeleteRes = await client.bulkWrite(clientDeletes);
245+
console.log(`Deleted documents: ${clientDeleteRes.deletedCount}`);
249246
// end-delete-client
250247

251248
console.log("Operations completed successfully.");

source/fundamentals/crud/write-operations/bulk.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ you can perform multiple operations within one action.
2424
in the {+mdb-server+} manual.
2525

2626
You can use bulk operations to perform multiple write operations on
27-
a collection. You can also call bulk operations on your client,
27+
a collection. You can also run bulk operations from the client,
2828
which allows you to perform bulk writes across multiple namespaces.
2929
In MongoDB, a namespace consists of the database name and the collection
3030
name in the format ``<database>.<collection>``.

0 commit comments

Comments
 (0)