com.github.cedrickring.reactormongodb.collection.mono.FindOneAndUpdateMono.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of reactor-mongodb Show documentation
Show all versions of reactor-mongodb Show documentation
A wrapper above the mongodb-async api with Reactor (http://projectreactor.io/)
The newest version!
package com.github.cedrickring.reactormongodb.collection.mono
import com.github.cedrickring.reactormongodb.collection.ReactiveCollection
import com.mongodb.client.model.FindOneAndUpdateOptions
import org.bson.conversions.Bson
import reactor.core.CoreSubscriber
import reactor.core.publisher.Mono
class FindOneAndUpdateMono(private val reactiveCollection: ReactiveCollection,
private val filter: Bson,
private val update: Bson,
private val findOneAndUpdateOptions: FindOneAndUpdateOptions) : Mono() {
override fun subscribe(actual: CoreSubscriber?) {
reactiveCollection.nativeCollection.findOneAndUpdate(filter, update, findOneAndUpdateOptions) { document, throwable ->
if (throwable == null) {
actual?.onNext(document)
} else {
actual?.onError(throwable)
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy