All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.cedrickring.reactormongodb.collection.flux.DistinctFlux.kt Maven / Gradle / Ivy

The newest version!
package com.github.cedrickring.reactormongodb.collection.flux

import com.github.cedrickring.reactormongodb.collection.ReactiveCollection
import org.bson.Document
import org.bson.conversions.Bson
import reactor.core.CoreSubscriber
import reactor.core.publisher.Flux

class DistinctFlux(private val reactiveCollection: ReactiveCollection,
                              private val fieldName: String,
                              private val filter: Bson?,
                              private val resultClass: Class) : Flux() {

    override fun subscribe(actual: CoreSubscriber?) {
        reactiveCollection.nativeCollection.distinct(fieldName, filter ?: Document(), resultClass)
                .forEach(
                        { result -> actual?.onNext(result) },
                        { _, throwable -> actual?.onError(throwable) }
                )
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy