@@ -4,10 +4,9 @@ import com.mongodb.ClientSessionOptions
44import com.mongodb.ConnectionString
55import com.mongodb.MongoClientSettings
66import com.mongodb.TransactionOptions
7- import com.mongodb.client.MongoClient
8- import com.mongodb.client.MongoClients
97import com.mongodb.client.cursor.TimeoutMode
108import com.mongodb.client.model.Filters
9+ import com.mongodb.kotlin.client.MongoClient
1110import org.bson.Document
1211import java.util.concurrent.TimeUnit
1312
@@ -19,14 +18,14 @@ class CsotExample {
1918 .timeout(200L , TimeUnit .MILLISECONDS )
2019 .build()
2120
22- val client = MongoClients .create(settings)
21+ val client = MongoClient .create(settings)
2322 // end-mongoclientsettings
2423 }
2524
2625 private fun connectionString () {
2726 // start-string
2827 val uri = " <connection string>/?timeoutMS=200"
29- val client = MongoClients .create(uri)
28+ val client = MongoClient .create(uri)
3029 // end-string
3130 }
3231
@@ -37,9 +36,9 @@ class CsotExample {
3736 .timeout(200L , TimeUnit .MILLISECONDS )
3837 .build()
3938
40- MongoClients .create(settings).use { mongoClient ->
39+ MongoClient .create(settings).use { mongoClient ->
4140 val database = mongoClient.getDatabase(" db" )
42- val collection = database.getCollection(" people" )
41+ val collection = database.getCollection< Document > (" people" )
4342 collection.insertOne(Document (" name" , " Francine Loews" ))
4443 }
4544 // end-operation-timeout
@@ -52,10 +51,10 @@ class CsotExample {
5251 .timeout(200L , TimeUnit .MILLISECONDS )
5352 .build()
5453
55- MongoClients .create(settings).use { mongoClient ->
54+ MongoClient .create(settings).use { mongoClient ->
5655 val database = mongoClient.getDatabase(" db" )
5756 val collection = database
58- .getCollection(" people" )
57+ .getCollection< Document > (" people" )
5958 .withTimeout(300L , TimeUnit .MILLISECONDS )
6059 }
6160 // end-override
@@ -65,10 +64,10 @@ class CsotExample {
6564 val settings = MongoClientSettings .builder()
6665 .applyConnectionString(ConnectionString (" <connection string>" ))
6766 .build()
68- MongoClients .create(settings).use { mongoClient ->
67+ MongoClient .create(settings).use { mongoClient ->
6968 val collection = mongoClient
7069 .getDatabase(" db" )
71- .getCollection(" people" )
70+ .getCollection< Document > (" people" )
7271
7372 // start-session-timeout
7473 val opts = ClientSessionOptions .builder()
@@ -93,10 +92,10 @@ class CsotExample {
9392 .timeout(200L , TimeUnit .MILLISECONDS )
9493 .build()
9594
96- MongoClients .create(settings).use { mongoClient ->
95+ MongoClient .create(settings).use { mongoClient ->
9796 val collection = mongoClient
9897 .getDatabase(" db" )
99- .getCollection(" people" )
98+ .getCollection< Document > (" people" )
10099
101100 // start-cursor-lifetime
102101 val cursorWithLifetimeTimeout = collection
0 commit comments