@@ -39,16 +39,16 @@ reconfiguring clients.
39
39
To learn how to retrieve your connection string in Atlas, see the
40
40
:atlas:`Atlas driver connection guide </driver-connection>`.
41
41
42
- The next part of the connection string contains your username and password
42
+ The next part of the connection string contains your credentials
43
43
if you are using password-based authentication. Replace the value of ``user``
44
44
with your username and ``pass`` with your password. If you are using an
45
45
authentication mechanism that does not require a username and password, omit
46
46
this part of the connection URI.
47
47
48
- The next part of the connection string specifies the hostname or IP address and
49
- port of your MongoDB instance. In the example above, we use ``sample.host``
50
- as the hostname and ``27017`` as the port. Replace these values to point to
51
- your MongoDB instance.
48
+ The next part of the connection string specifies the hostname or IP address of
49
+ your MongoDB instance, followed by the port number . In the example above, we use
50
+ ``sample.host`` as the hostname and ``27017`` as the port. Replace these values
51
+ to point to your MongoDB instance.
52
52
53
53
The last part of the connection string contains connection and authentication
54
54
options as parameters. In the example above, we set two connection options:
@@ -57,12 +57,27 @@ options, skip to the :ref:`node-connection-options` section.
57
57
58
58
.. _connect-sample-node-driver:
59
59
60
- The code below shows how you can use a connection URI in a client to
61
- connect to MongoDB.
60
+ Atlas Connection Example
61
+ ------------------------
62
62
63
- .. literalinclude:: /code-snippets/connection/connect.js
63
+ You must create a client to connect to a MongoDB deployment on Atlas. To create
64
+ a client, construct an instance of ``MongoClient``, passing in your
65
+ URI and a ``MongoClientOptions`` object.
66
+
67
+ Use the ``serverApi`` option in your ``MongoClientOptions`` object to
68
+ enable the {+stable-api+} feature, which forces the server to run operations
69
+ with behavior compatible with the specified API version.
70
+
71
+ The following code shows how you can specify the connection string and the
72
+ {+stable-api+} client option when connecting to a MongoDB deployment on Atlas and
73
+ verify that the connection is successful:
74
+
75
+ .. literalinclude:: /code-snippets/connection/stable-api-connect.js
64
76
:language: javascript
65
77
78
+ To learn more about the Stable
79
+ API feature, see the :ref:`{+stable-api+} page <nodejs-stable-api>`.
80
+
66
81
.. _node-other-ways-to-connect:
67
82
68
83
Other Ways to Connect to MongoDB
0 commit comments