Skip to content

Commit f797fdf

Browse files
authored
(DOCSP-29409, DOCSP-29158, DOCSP-29157): Add Kotlin driver to Drivers… (#879)
* (DOCSP-29409, DOCSP-29158, DOCSP-29157): Add Kotlin driver to Drivers site
1 parent c79ca72 commit f797fdf

File tree

8 files changed

+252
-8
lines changed

8 files changed

+252
-8
lines changed

snooty.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "drivers"
22
title = "MongoDB Drivers"
33

4-
toc_landing_pages = ["/python", "/php", "/java-drivers", "/use-cases", "/ruby"]
4+
toc_landing_pages = ["/python", "/php", "/java-drivers", "/kotlin", "/use-cases", "/ruby"]
55

66
intersphinx = ["https://www.mongodb.com/docs/manual/objects.inv"]
77
sharedinclude_root = "https://raw.githubusercontent.com/10gen/docs-shared/main/"
@@ -12,5 +12,6 @@ stable-api = "Stable API"
1212
node-driver-long = "MongoDB Node.js Driver"
1313
node-driver-short = "Node.js Driver"
1414

15-
java-version = "4.9"
15+
java-version = "4.10"
16+
java-version-full = "{+java-version+}.0"
1617
java-api = "https://mongodb.github.io/mongo-java-driver/{+java-version+}"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
How to get help
2+
---------------
3+
4+
- Ask questions on our :community-forum:`MongoDB Community Forums <>`.
5+
- Visit our :technical-support:`Support Channels </>`.
6+
- See `Issues & Help <https://www.mongodb.com/docs/drivers/kotlin/coroutine/current/issues-and-help/>`__.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.. list-table::
2+
:header-rows: 1
3+
:stub-columns: 1
4+
:class: compatibility-large
5+
6+
* - Kotlin Sync Driver Version
7+
- Kotlin 1.8
8+
9+
* - 4.10
10+
- ✓
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
.. sharedinclude:: dbx/compatibility-table-legend.rst
2+
3+
.. list-table::
4+
:header-rows: 1
5+
:stub-columns: 1
6+
:class: compatibility-large
7+
8+
* - Kotlin Sync Driver Version
9+
- MongoDB 6.1
10+
- MongoDB 6.0
11+
- MongoDB 5.0
12+
- MongoDB 4.4
13+
- MongoDB 4.2
14+
- MongoDB 4.0
15+
- MongoDB 3.6
16+
- MongoDB 3.4
17+
- MongoDB 3.2
18+
- MongoDB 3.0
19+
- MongoDB 2.6
20+
* - 4.10
21+
- ✓
22+
- ✓
23+
- ✓
24+
- ✓
25+
- ✓
26+
- ✓
27+
- ✓
28+
-
29+
-
30+
-
31+
-
32+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import com.mongodb.ConnectionString
2+
import com.mongodb.MongoClientSettings
3+
import com.mongodb.ServerApi
4+
import com.mongodb.ServerApiVersion
5+
import com.mongodb.kotlin.client.sync.MongoClient
6+
import com.mongodb.kotlin.client.sync.MongoDatabase
7+
8+
// Replace the placeholder with your MongoDB deployment's connection string
9+
val uri = "<connection string>"
10+
11+
// Set the Stable API version on the client
12+
val serverApi = ServerApi.builder()
13+
.version(ServerApiVersion.V1)
14+
.build()
15+
val settings = MongoClientSettings.builder()
16+
.applyConnectionString(ConnectionString(uri))
17+
.serverApi(serverApi)
18+
.build()
19+
20+
// Create a new client and connect to the server
21+
val mongoClient = MongoClient.create(settings)
22+
val database = mongoClient.getDatabase("test")

source/index.txt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ security patches to them.
4848
:icon: /figures/icons/java.svg
4949
:icon-alt: Java Driver icon
5050

51+
.. card::
52+
:headline: Kotlin
53+
:url: /kotlin/
54+
:icon: /figures/icons/kotlin.svg
55+
:icon-alt: Kotlin Driver icon
56+
5157
.. card::
5258
:headline: Node.js
5359
:url: https://www.mongodb.com/docs/drivers/node/current/
@@ -111,12 +117,6 @@ Featured Community-Supported Libraries
111117
:icon: /figures/icons/elixir.svg
112118
:icon-alt: Elixir icon
113119

114-
.. card::
115-
:cta: Kotlin
116-
:url: https://github.com/Litote/kmongo
117-
:icon: /figures/icons/kotlin.svg
118-
:icon-alt: Kotlin icon
119-
120120
.. card::
121121
:cta: Mongoose
122122
:url: https://mongoosejs.com/docs/index.html
@@ -145,6 +145,7 @@ Don’t see your desired language? Browse more `community-supported libraries <h
145145
C# and .NET Driver <https://www.mongodb.com/docs/drivers/csharp/current/>
146146
Go Driver <https://www.mongodb.com/docs/drivers/go/current/>
147147
Java Drivers </java-drivers>
148+
Kotlin Drivers </kotlin>
148149
Node.js Driver <https://www.mongodb.com/docs/drivers/node/current/>
149150
PHP Driver </php>
150151
Python Drivers </python>

source/kotlin-sync.txt

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
==================
2+
Kotlin Sync Driver
3+
==================
4+
5+
.. default-domain:: mongodb
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 1
11+
:class: twocols
12+
13+
14+
Introduction
15+
------------
16+
17+
Welcome to the documentation site for the Kotlin Sync Driver, the
18+
official MongoDB driver for synchronous Kotlin applications.
19+
20+
- `API Documentation <{+java-api+}/apidocs/mongodb-driver-kotlin-sync/>`__
21+
22+
- `Source Code <https://github.com/mongodb/mongo-java-driver/tree/master/driver-kotlin-sync/>`__
23+
24+
If you need to make asynchronous calls between your application and MongoDB with
25+
coroutines, use the :driver:`MongoDB Kotlin Coroutine Driver </kotlin/coroutine/current/>`
26+
instead of the Sync Driver.
27+
28+
Installation
29+
------------
30+
31+
The recommended way to get started using the driver in your project is with
32+
a dependency management system.
33+
34+
If you are using `Gradle <https://gradle.org/>`__, add the following to your
35+
``build.gradle.kts`` dependencies list:
36+
37+
.. code-block:: xml
38+
:caption: build.gradle.kts
39+
40+
dependencies {
41+
implementation("org.mongodb:mongodb-driver-kotlin-sync:{+java-version-full+}")
42+
}
43+
44+
If you are using `Maven <https://maven.apache.org/>`__, add the following to
45+
your ``pom.xml`` dependencies list:
46+
47+
.. code-block:: xml
48+
:caption: pom.xml
49+
50+
<dependencies>
51+
<dependency>
52+
<groupId>org.mongodb</groupId>
53+
<artifactId>mongodb-driver-kotlin-sync</artifactId>
54+
<version>{+java-version-full+}</version>
55+
</dependency>
56+
</dependencies>
57+
58+
.. _connect-atlas-kotlin-sync-driver:
59+
60+
Connect to MongoDB Atlas
61+
------------------------
62+
63+
.. include:: /includes/atlas-connect-blurb.rst
64+
65+
.. code-block:: kotlin
66+
67+
import com.mongodb.ConnectionString
68+
import com.mongodb.kotlin.client.sync.MongoClient
69+
import com.mongodb.kotlin.client.sync.MongoDatabase
70+
import com.mongodb.MongoClientSettings
71+
72+
// Replace the placeholder with your Atlas connection string
73+
val uri = "<connection string>"
74+
75+
val settings = MongoClientSettings.builder()
76+
.applyConnectionString(ConnectionString(uri))
77+
.retryWrites(true)
78+
.build()
79+
80+
// Create a new client and connect to the server
81+
val mongoClient = MongoClient.create(settings)
82+
val database = mongoClient.getDatabase("test")
83+
84+
.. include:: /includes/serverless-compatibility.rst
85+
86+
{+stable-api+}
87+
--------------
88+
89+
You can use the {+stable-api+} feature starting with MongoDB Server version
90+
5.0 and Kotlin Sync Driver. When you use the
91+
{+stable-api+} feature, you can update your driver or server without worrying
92+
about backward compatibility issues with any commands covered by the
93+
{+stable-api+}.
94+
95+
.. include:: /includes/stable-api-notice.rst
96+
97+
To use this feature, construct a MongoDB client instance, specifying a version
98+
of the {+stable-api+}:
99+
100+
.. literalinclude:: /includes/stable-api-snippets/kotlin-sync-client.kt
101+
:language: kotlin
102+
103+
Connect to a MongoDB Server on Your Local Machine
104+
-------------------------------------------------
105+
106+
.. include:: /includes/localhost-connection.rst
107+
108+
To test whether you can connect to your server, replace the connection
109+
string in the :ref:`Connect to MongoDB Atlas <connect-atlas-kotlin-sync-driver>`
110+
code example and run it.
111+
112+
Compatibility
113+
-------------
114+
115+
MongoDB Compatibility
116+
~~~~~~~~~~~~~~~~~~~~~
117+
118+
The following compatibility table specifies the recommended version(s) of
119+
the MongoDB Kotlin Sync driver for use with a specific version of MongoDB.
120+
121+
The first column lists the driver version(s).
122+
123+
.. include:: /includes/mongodb-compatibility-table-kotlin-sync.rst
124+
125+
.. include:: /includes/older-server-versions-unsupported.rst
126+
127+
Language Compatibility
128+
~~~~~~~~~~~~~~~~~~~~~~
129+
130+
The following compatibility table specifies the recommended version(s) of the
131+
MongoDB Kotlin Sync driver for use with a specific version of Kotlin.
132+
133+
The first column lists the driver version(s).
134+
135+
.. include:: /includes/language-compatibility-table-kotlin-sync.rst
136+
137+
.. include:: /includes/about-driver-compatibility.rst
138+
139+
.. include:: /includes/help-links-kotlin.rst
140+

source/kotlin.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
.. _kotlin-language-center:
2+
3+
======================
4+
MongoDB Kotlin Drivers
5+
======================
6+
7+
.. default-domain:: mongodb
8+
9+
.. toctree::
10+
:titlesonly:
11+
12+
Kotlin Coroutine Driver <https://www.mongodb.com/docs/drivers/kotlin/coroutine/current/>
13+
/kotlin-sync.txt
14+
15+
.. contents:: On this page
16+
:local:
17+
:backlinks: none
18+
:depth: 1
19+
:class: singlecol
20+
21+
Introduction
22+
------------
23+
24+
Welcome to the documentation site for the official MongoDB Kotlin
25+
drivers. You can add one of the following drivers to your application
26+
to work with MongoDB in Kotlin:
27+
28+
- Use the
29+
`Kotlin Coroutine Driver <https://www.mongodb.com/docs/drivers/kotlin/coroutine/current>`__
30+
for Kotlin applications using coroutines.
31+
32+
- Use the :doc:`Kotlin Sync Driver </kotlin-sync>` for synchronous Kotlin applications.

0 commit comments

Comments
 (0)