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

com.github.cedrickring.reactormongodb.collection.mono.FindOneAndDeleteMono.kt Maven / Gradle / Ivy

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

import com.github.cedrickring.reactormongodb.collection.ReactiveCollection
import com.mongodb.client.model.FindOneAndDeleteOptions
import org.bson.conversions.Bson
import reactor.core.CoreSubscriber
import reactor.core.publisher.Mono

class FindOneAndDeleteMono(private val reactiveCollection: ReactiveCollection,
                              private val filter: Bson,
                              private val findOneAndDeleteOptions: FindOneAndDeleteOptions) : Mono() {

    override fun subscribe(actual: CoreSubscriber?) {
        reactiveCollection.nativeCollection.findOneAndDelete(filter, findOneAndDeleteOptions) { document, throwable ->
            if (throwable == null) {
                actual?.onNext(document)
            } else {
                actual?.onError(throwable)
            }
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy