Skip to content

Commit d7a2f49

Browse files
committed
DOCSP-32718: runCommand comments
1 parent 6d1c8ac commit d7a2f49

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
11
import { MongoClient } from "mongodb";
22

3-
// Replace the uri string with your MongoDB deployment's connection string.
3+
// Replace the uri string with your MongoDB deployment's connection string
44
const uri = "<connection string uri>";
55

6+
// Create a new instance of the MongoClient using the provided URI
67
const client = new MongoClient(uri);
78

9+
// Define a function to interact with the MongoDB database
810
async function run() {
911
try {
1012
// start-runcommand
13+
// Connect to the "testDB" database
1114
const db = client.db("testDB");
15+
16+
// Run a cursor command to check metadata consistency within the database
1217
const cursor = await db.runCursorCommand({
1318
checkMetadataConsistency: 1,
1419
});
20+
// Iterate through the cursor's results and log each document
1521
for await (const doc of cursor) {
1622
console.log(doc);
1723
}
1824
// end-runcommand
1925
} finally {
26+
// Close the MongoDB client connection
2027
await client.close();
2128
}
2229
}
30+
// Call the "run" function and handle any errors using console.dir
2331
run().catch(console.dir);
2432

0 commit comments

Comments
 (0)