Skip to content

Commit 1e91bff

Browse files
committed
code fix
1 parent 07a2f57 commit 1e91bff

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

source/includes/databases-collections.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,21 @@ fun main() {
1717
.retryWrites(true)
1818
.build()
1919

20-
val mongoClient = MongoClient.create(settings)
21-
val database = mongoClient.getDatabase("sample_restaurants")
22-
val collection = database.getCollection<Restaurant>("restaurants")
20+
val client = MongoClient.create(settings)
2321

2422
// Accesses the "test_database" database
2523
// start-access-database
26-
val db: MongoDatabase = client.getDatabase("test_database")
24+
val db = client.getDatabase("test_database")
2725
// end-access-database
2826

2927
// Accesses the "test_collection" collection
3028
// start-access-collection
31-
val collection: MongoCollection<Document> = client.getDatabase("test_database").getCollection("test_collection")
29+
val collection = db.getCollection<Document>("test_collection")
3230
// end-access-collection
3331

3432
// Explicitly creates the "example_collection" collection
3533
// start-create-collection
36-
client.getDatabase("test_database").createCollection("example_collection")
34+
db.createCollection("example_collection")
3735
// end-create-collection
3836

3937
// Lists the collections in the "test_database" database
@@ -46,6 +44,6 @@ fun main() {
4644

4745
// Deletes the "test_collection" collection
4846
// start-drop-collection
49-
client.getDatabase("test_database").getCollection("test_collection").drop()
47+
db.getCollection<Document>("test_collection").drop()
5048
// end-drop-collection
5149
}

0 commit comments

Comments
 (0)