Skip to content

Commit 58ba4b8

Browse files
committed
add api doc section
1 parent 520ff3e commit 58ba4b8

File tree

2 files changed

+11
-26
lines changed

2 files changed

+11
-26
lines changed

source/connect/mongoclient.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Connection URI
4141
A standard connection string includes the following components:
4242

4343
.. TODO, add this as last sentence for ``username:password`` description: For more information about the ``authSource``
44-
connection option, see :ref:`kotlin-sync-auth`.
44+
.. connection option, see :ref:`kotlin-sync-auth`.
4545

4646
.. list-table::
4747
:widths: 20 80
@@ -109,3 +109,12 @@ and verify that the connection is successful:
109109
:language: kotlin
110110
:copyable:
111111
:dedent:
112+
113+
API Documentation
114+
-----------------
115+
116+
For more information about creating a ``MongoClient`` object with the
117+
{+driver-short+}, see the following API documentation:
118+
119+
- `MongoClient <{+api+}/mongodb-driver-kotlin-sync/com.mongodb.kotlin.client/-mongo-client/index.html>`__
120+
- `MongoClientSettings <{+core-api+}com/mongodb/MongoClientSettings.html>`__

source/includes/connect/mongoclient.kt

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import org.bson.BsonInt64
44
import org.bson.Document
55

66
fun main() {
7-
8-
7+
98
// start-connect-to-atlas
109
// Replace the placeholder with your Atlas connection string
1110
val uri = "<connection string>"
@@ -32,27 +31,4 @@ fun main() {
3231
System.err.println(me)
3332
}
3433
// end-connect-to-atlas
35-
36-
// Replication set connection options
37-
38-
// Using ConnectionString class
39-
// start-replica-set-connection-string
40-
val connectionString = ConnectionString("mongodb://host1:27017,host2:27017,host3:27017/")
41-
val mongoClient = MongoClient.create(connectionString)
42-
// end-replica-set-connection-string
43-
44-
// Using MongoClientSettings class
45-
// start-replica-set-client-settings
46-
val seed1 = ServerAddress("host1", 27017)
47-
val seed2 = ServerAddress("host2", 27017)
48-
val seed3 = ServerAddress("host3", 27017)
49-
val settings = MongoClientSettings.builder()
50-
.applyToClusterSettings { builder ->
51-
builder.hosts(
52-
listOf(seed1, seed2, seed3)
53-
)
54-
}
55-
.build()
56-
val mongoClient = MongoClient.create(settings)
57-
// end-replica-set-client-settings
5834
}

0 commit comments

Comments
 (0)