com.github.cedrickring.reactormongodb.collection.mono.CountMono.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.CountOptions
import org.bson.Document
import org.bson.conversions.Bson
import reactor.core.CoreSubscriber
import reactor.core.publisher.Mono
class CountMono(private val reactiveCollection: ReactiveCollection,
private val filter: Bson?,
private val countOptions: CountOptions?) : Mono() {
override fun subscribe(actual: CoreSubscriber?) {
reactiveCollection.nativeCollection.count(filter ?: Document(), countOptions
?: CountOptions()) { count, throwable ->
if (throwable != null) {
actual?.onError(throwable)
} else {
actual?.onNext(count)
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy