Skip to content

Commit c607ef8

Browse files
authored
DOCSP-32718: runCommand comments (#762)
* DOCSP-32718: runCommand comments * feedback
1 parent e21df54 commit c607ef8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
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 client and connect to MongoDB
67
const client = new MongoClient(uri);
78

89
async function run() {
910
try {
1011
// start-runcommand
12+
// Connect to the "testDB" database
1113
const db = client.db("testDB");
14+
15+
// Run a cursor command to check metadata consistency within the database
1216
const cursor = await db.runCursorCommand({
1317
checkMetadataConsistency: 1,
1418
});
19+
// Iterate through the cursor's results and print the contents
1520
for await (const doc of cursor) {
1621
console.log(doc);
1722
}
1823
// end-runcommand
1924
} finally {
25+
// Close the MongoDB client connection
2026
await client.close();
2127
}
2228
}
29+
// Run the function and handle any errors
2330
run().catch(console.dir);
2431

0 commit comments

Comments
 (0)