com.github.cedrickring.reactormongodb.collection.mono.InsertOneMono.kt Maven / Gradle / Ivy
package com.github.cedrickring.reactormongodb.collection.mono
import com.github.cedrickring.reactormongodb.collection.ReactiveCollection
import com.mongodb.client.model.InsertOneOptions
import reactor.core.CoreSubscriber
import reactor.core.publisher.Mono
class InsertOneMono(private val reactiveCollection: ReactiveCollection,
private val document: T,
private val insertOneOptions: InsertOneOptions) : Mono() {
override fun subscribe(actual: CoreSubscriber?) {
reactiveCollection.nativeCollection.insertOne(document, insertOneOptions) { void, throwable ->
if (throwable == null) {
actual?.onNext(void)
} else {
actual?.onError(throwable)
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy