File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -17,23 +17,21 @@ fun main() {
17
17
.retryWrites(true )
18
18
.build()
19
19
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)
23
21
24
22
// Accesses the "test_database" database
25
23
// start-access-database
26
- val db: MongoDatabase = client.getDatabase(" test_database" )
24
+ val db = client.getDatabase(" test_database" )
27
25
// end-access-database
28
26
29
27
// Accesses the "test_collection" collection
30
28
// start-access-collection
31
- val collection: MongoCollection < Document > = client.getDatabase( " test_database " ). getCollection(" test_collection" )
29
+ val collection = db. getCollection< Document > (" test_collection" )
32
30
// end-access-collection
33
31
34
32
// Explicitly creates the "example_collection" collection
35
33
// start-create-collection
36
- client.getDatabase( " test_database " ) .createCollection(" example_collection" )
34
+ db .createCollection(" example_collection" )
37
35
// end-create-collection
38
36
39
37
// Lists the collections in the "test_database" database
@@ -46,6 +44,6 @@ fun main() {
46
44
47
45
// Deletes the "test_collection" collection
48
46
// start-drop-collection
49
- client.getDatabase( " test_database " ). getCollection(" test_collection" ).drop()
47
+ db. getCollection< Document > (" test_collection" ).drop()
50
48
// end-drop-collection
51
49
}
You can’t perform that action at this time.
0 commit comments