Skip to content

Commit 97d06cb

Browse files
authored
DOCSP-27919: stableapi connection for atlas (#79)
* DOCSP-27919: stableapi connection for atlas * MW suggestions * Empty commit
1 parent b8bebe3 commit 97d06cb

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

source/fundamentals/connection/connect.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ Other Connection Targets
8787
Connect to Atlas
8888
~~~~~~~~~~~~~~~~
8989

90-
In the following example, the driver uses a sample connection URI to connect to a MongoDB instance on Atlas with the credentials ``user1`` and ``password1``:
90+
In the following example, the driver uses a sample connection URI to
91+
connect to a MongoDB instance on Atlas, using placeholders for your
92+
username and password. In this example, the client uses
93+
the :ref:`Stable API <csharp-stable-api>` feature, though
94+
you can connect to Atlas without this feature.
9195

9296
.. literalinclude:: /includes/fundamentals/code-examples/connection/AtlasConnection.cs
9397
:language: csharp
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
using MongoDB.Driver;
22

33
// Connection URI
4-
const string connectionUri = "mongodb+srv://user1:[email protected]/?retryWrites=true&w=majority";
4+
const string connectionUri = "mongodb+srv://<username>:<password>@cluster0.sample.mongodb.net/?retryWrites=true&w=majority";
5+
6+
var serverApi = new ServerApi(ServerApiVersion.V1);
7+
var settings = MongoClientSettings.FromConnectionString(connectionString);
8+
settings.ServerApi = serverApi;
59

610
// Create a new client and connect to the server
7-
var client = new MongoClient(connectionUri);
11+
var client = new MongoClient(settings);

0 commit comments

Comments
 (0)