Skip to content

Commit edf7402

Browse files
author
Mohammad Hunan Chughtai
authored
Make client connection code consistent (#59)
* made client cconn code consistent * added admonition * fixed link * moved note into INCLUDES and literal included * updated to rst * made node external * Attempt to fix formatting * included note in usage ex * removed unneeded comma * moved useUnifiedTopology out of uri * updated location of note * placement of connection-guide link node * Removed unneeded spacing
1 parent abf8987 commit edf7402

27 files changed

+57
-48
lines changed

source/code-snippets/usage-examples/bulkWrite-example.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
const { MongoClient } = require("mongodb");
22
const fs = require("fs");
33

4-
// Replace the following with your MongoDB deployment's connection
5-
// string.
4+
// Replace the following string with your MongoDB deployment's connection string.
65
const uri =
76
"mongodb+srv://<user>:<password>@<cluster-url>?retryWrites=true&w=majority";
87

9-
const client = new MongoClient(uri, {
10-
useNewUrlParser: true,
11-
useUnifiedTopology: true
12-
});
8+
const client = new MongoClient(uri, { useUnifiedTopology: true });
139

1410
async function run() {
1511
try {

source/code-snippets/usage-examples/command.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// ignored first line
22
const { MongoClient } = require("mongodb");
33

4-
// Replace the following with your MongoDB deployment's connection string.
4+
// Replace the following string with your MongoDB deployment's connection string.
55
const uri =
66
"mongodb+srv://<user>:<password>@<cluster-url>?retryWrites=true&w=majority";
77

8-
const client = new MongoClient(uri);
8+
const client = new MongoClient(uri, { useUnifiedTopology: true });
99

1010
async function run() {
1111
try {

source/code-snippets/usage-examples/count.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
// ignored first line
22
const { MongoClient } = require("mongodb");
33

4-
// Replace the following with your MongoDB deployment's connection
5-
// string.
4+
// Replace the following string with your MongoDB deployment's connection string.
65
const uri =
76
"mongodb+srv://<user>:<password>@<cluster-url>?retryWrites=true&w=majority";
87

9-
const client = new MongoClient(uri, {
10-
useNewUrlParser: true,
11-
useUnifiedTopology: true,
12-
});
8+
const client = new MongoClient(uri, { useUnifiedTopology: true });
139

1410
async function run() {
1511
try {

source/code-snippets/usage-examples/deleteMany.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
// ignored first line
22
const { MongoClient } = require("mongodb");
33

4-
// Replace the following with your MongoDB deployment's connection
5-
// string.
4+
// Replace the following string with your MongoDB deployment's connection string.
65
const uri =
76
"mongodb+srv://<user>:<password>@<cluster-url>?retryWrites=true&w=majority";
87

9-
const client = new MongoClient(uri, {
10-
useNewUrlParser: true,
11-
useUnifiedTopology: true,
12-
});
8+
const client = new MongoClient(uri, { useUnifiedTopology: true });
139

1410
async function run() {
1511
try {

source/code-snippets/usage-examples/deleteOne.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
// ignored first line
22
const { MongoClient } = require("mongodb");
33

4-
// Replace the following with your MongoDB deployment's connection
5-
// string.
4+
// Replace the following string with your MongoDB deployment's connection string.
65
const uri =
76
"mongodb+srv://<user>:<password>@<cluster-url>?retryWrites=true&w=majority";
87

9-
const client = new MongoClient(uri, {
10-
useNewUrlParser: true,
11-
useUnifiedTopology: true,
12-
});
8+
const client = new MongoClient(uri, { useUnifiedTopology: true });
139

1410
async function run() {
1511
try {

source/code-snippets/usage-examples/distinct.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
// ignored first line
22
const { MongoClient } = require("mongodb");
33

4+
// Replace the following string with your MongoDB deployment's connection string.
45
const uri =
56
"mongodb+srv://<user>:<password>@<cluster-url>?retryWrites=true&w=majority";
67

7-
const client = new MongoClient(uri);
8+
const client = new MongoClient(uri, { useUnifiedTopology: true });
89

910
async function run() {
1011
try {
@@ -22,7 +23,6 @@ async function run() {
2223

2324
const distinctValues = await collection.distinct(fieldName, query);
2425
console.log(distinctValues);
25-
2626
} finally {
2727
await client.close();
2828
}

source/code-snippets/usage-examples/find.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
// ignored first line
22
const { MongoClient } = require("mongodb");
33

4-
// Replace the following with your MongoDB deployment's connection
5-
// string.
4+
// Replace the following string with your MongoDB deployment's connection string.
65
const uri =
76
"mongodb+srv://<user>:<password>@<cluster-url>?retryWrites=true&w=majority";
87

9-
const client = new MongoClient(uri, {
10-
useNewUrlParser: true,
11-
useUnifiedTopology: true,
12-
});
8+
const client = new MongoClient(uri, { useUnifiedTopology: true });
139

1410
async function run() {
1511
try {

source/code-snippets/usage-examples/findOne.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
// ignored first line
22
const { MongoClient } = require("mongodb");
33

4-
// Replace the following with your MongoDB deployment's connection
5-
// string.
4+
// Replace the following string with your MongoDB deployment's connection string.
65
const uri =
76
"mongodb+srv://<user>:<password>@<cluster-url>?retryWrites=true&w=majority";
87

9-
const client = new MongoClient(uri, {
10-
useNewUrlParser: true,
11-
useUnifiedTopology: true,
12-
});
8+
const client = new MongoClient(uri, { useUnifiedTopology: true });
139

1410
async function run() {
1511
try {

source/code-snippets/usage-examples/insertMany.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
// ignored first line
22
const { MongoClient } = require("mongodb");
33

4+
// Replace the following string with your MongoDB deployment's connection string.
45
const uri =
56
"mongodb+srv://<user>:<password>@<cluster-url>?retryWrites=true&w=majority";
67

7-
const client = new MongoClient(uri);
8+
const client = new MongoClient(uri, { useUnifiedTopology: true });
89

910
async function run() {
1011
try {

source/code-snippets/usage-examples/insertOne.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
// ignored first line
22
const { MongoClient } = require("mongodb");
33

4+
// Replace the following string with your MongoDB deployment's connection string.
45
const uri =
56
"mongodb+srv://<user>:<password>@<cluster-url>?retryWrites=true&w=majority";
67

7-
const client = new MongoClient(uri);
8+
const client = new MongoClient(uri, { useUnifiedTopology: true });
89

910
async function run() {
1011
try {

0 commit comments

Comments
 (0)