-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kim Hendrick
committed
May 2, 2024
1 parent
543dd2f
commit 00e31f4
Showing
4 changed files
with
46 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 10 additions & 2 deletions
12
components/data-documents/src/main/kotlin/io/initialcapacity/documents/QueryDocuments.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
package io.initialcapacity.documents | ||
|
||
import com.mongodb.ConnectionString | ||
import com.mongodb.kotlin.client.coroutine.MongoClient | ||
import kotlinx.coroutines.flow.toList | ||
|
||
class QueryDocuments() { | ||
fun list(): List<Document> { | ||
return listOf(Document("Lorem Ipsum...")) | ||
suspend fun list(): List<Document> { | ||
val connectionString = ConnectionString("mongodb://localhost:27017") | ||
val mongoClient = MongoClient.create(connectionString) | ||
val db = mongoClient.getDatabase("test") | ||
val collection = db.getCollection<Document>("documents") | ||
return collection.find().toList() | ||
} | ||
} |