Skip to content

Commit ed5141c

Browse files
authored
DOCSP-6066 Add w=majority to all Atlas connection snippets (#517)
1 parent 7ee9be2 commit ed5141c

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

source/drivers/c.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ To connect to a `MongoDB Atlas <https://docs.atlas.mongodb.com/>`_ cluster, use
6060
mongoc_init ();
6161

6262
client = mongoc_client_new(
63-
"mongodb+srv://<username>:<password>@<cluster-url>/test?retryWrites=true"
63+
"mongodb+srv://<username>:<password>@<cluster-url>/test?retryWrites=true&w=majority"
6464
);
6565
database = mongoc_client_get_database (client, "test");
6666

source/drivers/csharp.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ To connect to a `MongoDB Atlas <https://docs.atlas.mongodb.com/>`_ cluster, use
5151
using MongoDB.Driver;
5252
// ...
5353
var client = new MongoClient(
54-
"mongodb+srv://<username>:<password>@<cluster-address>/test"
54+
"mongodb+srv://<username>:<password>@<cluster-address>/test?w=majority"
5555
);
5656
var database = client.GetDatabase("test");
5757

source/drivers/cxx.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ To connect to a `MongoDB Atlas <https://docs.atlas.mongodb.com/>`_ cluster, use
5252
mongocxx::instance inst{}; // This should be done only once.
5353
mongocxx::client conn{
5454
mongocxx::uri{
55-
"mongodb+srv://<username>:<password>@<cluster-url>/test?retryWrites=true"
55+
"mongodb+srv://<username>:<password>@<cluster-url>/test?retryWrites=true&w=majority"
5656
}
5757
};
5858
mongocxx::database db = conn["test"];

source/drivers/go.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ To connect to a `MongoDB Atlas <https://docs.atlas.mongodb.com/>`_ cluster, use
5555

5656
ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
5757
client, err := mongo.Connect(ctx, options.Client().ApplyURI(
58-
"mongodb+srv://<username>:<password>@<cluster-address>/test"
58+
"mongodb+srv://<username>:<password>@<cluster-address>/test?w=majority"
5959
))
6060
if err != nil { log.Fatal(err) }
6161

source/drivers/java.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ To connect to a `MongoDB Atlas <https://docs.atlas.mongodb.com/>`_ cluster, use
6666

6767
// ...
6868
ConnectionString connString = new ConnectionString(
69-
"mongodb+srv://<username>:<password>@<cluster-address>/test"
69+
"mongodb+srv://<username>:<password>@<cluster-address>/test?w=majority"
7070
);
7171
MongoClientSettings settings = MongoClientSettings.builder()
7272
.applyConnectionString(connString)

source/drivers/node.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ To connect to a `MongoDB Atlas <https://docs.atlas.mongodb.com/>`_ cluster, use
6969
.. code-block:: javascript
7070

7171
const MongoClient = require('mongodb').MongoClient;
72-
const uri = "mongodb+srv://<username>:<password>@<your-cluster-url>/test?retryWrites=true";
72+
const uri = "mongodb+srv://<username>:<password>@<your-cluster-url>/test?retryWrites=true&w=majority";
7373
const client = new MongoClient(uri, { useNewUrlParser: true });
7474
client.connect(err => {
7575
const collection = client.db("test").collection("devices");

0 commit comments

Comments
 (0)