Skip to content

Commit 65c529f

Browse files
author
Chris Cho
committed
DOCSP-32718: add CodeWhisperer comments to SOCKS5 code snippet (#765)
* DOCSP-32718: add CodeWhisperer comments to SOCKS5 code snippet (cherry picked from commit 72bfca1)
1 parent 3f9a672 commit 65c529f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

source/code-snippets/connection/socks.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
11
import { MongoClient } from "mongodb";
22

33
// start-socks
4+
// Replace the placeholder with your connection string
45
const uri = "<connection string uri>";
56

7+
// Replace the placeholders with your SOCKS5 proxy server details
68
const socksOptions = {
79
proxyHost: "<host>",
810
proxyPort: 1080,
911
proxyUsername: "<username>",
1012
proxyPassword: "<password>",
1113
};
1214

15+
// Create a new client with the proxy server details
1316
const client = new MongoClient(uri, socksOptions);
1417
// end-socks
1518

19+
// Retrieve the first document from the MongoDB collection and print it
1620
async function run() {
1721
try {
1822
const db = client.db("myDB");
1923
const myColl = db.collection("myColl");
2024
const doc = await myColl.findOne({});
2125
console.log(doc);
2226
} finally {
27+
// Close the connection after the operation completes
2328
await client.close();
2429
}
2530
}

0 commit comments

Comments
 (0)