Skip to content
Kotlin coroutine support for MongoDB built on top of the official Reactive Streams Java Driver
Kotlin
Branch: master
Clone or download
Latest commit 6fac065 Oct 20, 2019

README.md

fluid-mongo

Maven Central JCenter Kotlin MongoDB #fluid-libraries Slack Channel

Kotlin coroutine support for MongoDB built on top of the official MongoDB Reactive Streams Java Driver.

Installation

build.gradle.kts:

dependencies {
    implementation("io.fluidsonic.mongo:fluid-mongo:1.0.0-beta.2")
}

Example

import io.fluidsonic.mongo.MongoClients
import org.bson.Document


suspend fun main() {
    val collection = MongoClients.create()
        .getDatabase("test")
        .getCollection("test")

    collection.insertOne(Document("hello", "world"))    // suspending call
    collection.insertOne(Document("it's", "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


Awesome Kotlin

You can’t perform that action at this time.