https://github.com/fluidsonic/fluid-mongo
Kotlin coroutine support for MongoDB built on top of the official Reactive Streams Java Driver
https://github.com/fluidsonic/fluid-mongo
coroutines kotlin kotlin-coroutines mongodb
Last synced: 5 months ago
JSON representation
Kotlin coroutine support for MongoDB built on top of the official Reactive Streams Java Driver
- Host: GitHub
- URL: https://github.com/fluidsonic/fluid-mongo
- Owner: fluidsonic
- License: apache-2.0
- Created: 2018-10-05T00:58:02.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-06-24T02:44:57.000Z (over 2 years ago)
- Last Synced: 2025-04-14T05:51:38.826Z (8 months ago)
- Topics: coroutines, kotlin, kotlin-coroutines, mongodb
- Language: Kotlin
- Homepage:
- Size: 519 KB
- Stars: 33
- Watchers: 2
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
fluid-mongo
===========
[](https://search.maven.org/artifact/io.fluidsonic.mongo/fluid-mongo)
[](https://github.com/JetBrains/kotlin/releases/v1.8.22)
[](https://github.com/mongodb/mongo-java-driver/releases/tag/r4.10.0)
[](https://kotlinlang.slack.com/messages/C7UDFSVT2/)
Kotlin coroutine support for MongoDB built on top of the
official [MongoDB Reactive Streams Java Driver](https://mongodb.github.io/mongo-java-driver/4.10/driver-reactive/).
Installation
------------
`build.gradle.kts`:
```kotlin
dependencies {
implementation("io.fluidsonic.mongo:fluid-mongo:1.7.0")
}
```
Example
-------
```kotlin
import io.fluidsonic.mongo.MongoClients
import org.bson.Document
suspend fun main() {
val collection = MongoClients.create()
.getDatabase("test")
.getCollection("test")
collection.insertOne(mapOf("hello" to "world")) // suspending call
collection.insertOne(mapOf("it's" to "so easy!")) // suspending call
collection.find().collect { document -> // Kotlin Flow
println(document)
}
}
```
Output:
```
Document{{_id=5bb6b56f9cfa62686b5afc87, hello=world}}
Document{{_id=5bb6b56f9cfa62686b5afc88, it's=so easy!}}
```
License
-------
Apache 2.0
--------------------------
[](https://github.com/KotlinBy/awesome-kotlin)