@@ -25,7 +25,7 @@ To connect to a MongoDB deployment, you need two things:
25
25
- A **connection URI**, also known as a *connection string*, which tells the {+driver-short+}
26
26
which MongoDB deployment to connect to.
27
27
- A **MongoClient** object, which creates the connection to and perform
28
- opertions on the MongoDB deployment.
28
+ operations on the MongoDB deployment.
29
29
30
30
You can also use either of these components to customize the way the {+driver-short+} behaves
31
31
while connected to MongoDB.
@@ -40,8 +40,6 @@ Connection URI
40
40
41
41
A standard connection string includes the following components:
42
42
43
- .. Any ref for authentication? Are we planning on making a page for authentication?
44
-
45
43
.. list-table::
46
44
:widths: 20 80
47
45
:header-rows: 1
@@ -58,8 +56,9 @@ A standard connection string includes the following components:
58
56
59
57
- Optional. Authentication credentials. If you include these, the client
60
58
authenticates the user against the database specified in ``authSource``.
61
- For more information about the ``authSource`` connection option, see
62
- :ref:`pymongo-auth`.
59
+
60
+ .. TODO, add this as last sentence for ``username:password``: For more information about the ``authSource`` connection option, see
61
+ :ref:`kotlin-sync-auth`.
63
62
64
63
* - ``host[:port]``
65
64
@@ -80,23 +79,21 @@ A standard connection string includes the following components:
80
79
:ref:`kotlin-sync-connection-options` for a full description of
81
80
these options.
82
81
83
- .. Is there relevant connection string content for kotlin sync to ref to? Only see for java sync.
84
-
85
82
For more information about creating a connection string, see
86
83
:manual:`Connection Strings </reference/connection-string?tck=docs_driver_kotlin>` in the
87
84
MongoDB Server documentation.
88
85
89
86
Atlas Connection Example
90
87
------------------------
91
88
92
- To connect to a MongoDB deployment on Atlas, create a client. You can create a
93
- client that uses your connection string and other client options by passing a
89
+ To connect to a MongoDB deployment on Atlas, you must first create a client.
90
+ You can create a client with your desired configurations by passing a
94
91
``MongoClientSettings`` object to the ``MongoClient.create()`` method.
95
92
96
93
To instantiate a ``MongoClientSettings`` object, use the builder method to
97
- specify your connection string and any other client options, and then call
98
- the ``build()`` method. Chain the ``applyConnectionString()``` method to the
99
- builder to specify your connection URI .
94
+ specify your connection string, using the ``applyConnectionString()`` method,
95
+ and any other client options. Once you have your desired configuration,
96
+ call the ``build()`` method .
100
97
101
98
You can set the Stable API version client option to avoid breaking changes when
102
99
you upgrade to a new server version. To learn more about the Stable API feature,
@@ -112,99 +109,3 @@ and verify that the connection is successful:
112
109
:language: kotlin
113
110
:copyable:
114
111
:dedent:
115
-
116
- Connect to a MongoDB Server or Replica Set
117
- ------------------------------------------
118
-
119
- If you are connecting to a single MongoDB server instance or a MongoDB
120
- replica set, see the following sections to find out how to connect.
121
-
122
- .. _connect-local-kotlin-sync-driver:
123
-
124
- Connect to a MongoDB Server on Your Local Machine
125
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
126
-
127
- If you need to run a MongoDB server on your local machine for development
128
- purposes instead of using an Atlas cluster, you need to complete the following:
129
-
130
- 1. Download the `Community <https://www.mongodb.com/try/download/community>`__
131
- or `Enterprise <https://www.mongodb.com/try/download/enterprise>`__ version
132
- of MongoDB Server.
133
-
134
- #. :ref:`Install and configure <tutorials-installation>`
135
- MongoDB Server.
136
-
137
- #. Start the server.
138
-
139
- .. important::
140
-
141
- Always secure your MongoDB server from malicious attacks. See our
142
- :manual:`Security Checklist </administration/security-checklist/>` for a
143
- list of security recommendations.
144
-
145
- After you successfully start your MongoDB server, specify your connection
146
- string in your driver connection code.
147
-
148
- If your MongoDB Server is running locally, you can use the connection string
149
- ``"mongodb://localhost:<port>"`` where ``<port>`` is the port number you
150
- configured your server to listen for incoming connections. If the port number
151
- is not specified, the default port ``27017`` is used.
152
-
153
- If you need to specify a different hostname or IP address, see our Server
154
- Manual entry on :manual:`Connection Strings </reference/connection-string/>`.
155
-
156
- .. _connect-replica-set:
157
-
158
- Connect to a MongoDB Replica Set
159
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
160
-
161
- A MongoDB replica set deployment is a group of connected instances that
162
- store the same set of data. This configuration of instances provides data
163
- redundancy and high data availability.
164
-
165
- To connect to a replica set deployment, specify the hostnames (or IP
166
- addresses) and port numbers of the members of the replica set.
167
-
168
- If you are not able to provide a full list of hosts in the replica set,
169
- you can specify a single or subset of the hosts in the replica and
170
- instruct the driver to perform automatic discovery in one of the following
171
- ways:
172
-
173
- - Specify the name of the replica set as the value of the ``replicaSet``
174
- parameter
175
- - Specify ``false`` as the value of the ``directConnection`` parameter
176
- - Specify more than one host in the replica set
177
-
178
- .. tip::
179
-
180
- Although you can specify a subset of the hosts in a replica set,
181
- include all the hosts in the replica set to ensure the driver is able to
182
- establish the connection if one of the hosts are unreachable.
183
-
184
- .. _mongo-client-settings-multiple-hosts:
185
-
186
- The following examples show how to specify multiple hosts to a ``MongoClient``
187
- instance using either the ``ConnectionString`` or ``MongoClientSettings``
188
- class. Select the tab that corresponds to your preferred class.
189
-
190
- .. tabs::
191
-
192
- .. tab:: ConnectionString
193
- :tabid: connectionstring
194
-
195
- .. literalinclude:: /includes/connect/mongoclient.kt
196
- :start-after: start-replica-set-connection-string
197
- :end-before: end-replica-set-connection-string
198
- :language: kotlin
199
- :copyable:
200
- :dedent:
201
-
202
- .. tab:: MongoClientSettings
203
- :tabid: mongoclientsettings
204
-
205
- .. literalinclude:: /includes/connect/mongoclient.kt
206
- :start-after: start-replica-set-client-settings
207
- :end-before: end-replica-set-client-settings
208
- :language: kotlin
209
- :copyable:
210
- :dedent:
0 commit comments