Search in sources :

Example 1 with DecrementOptions

use of com.couchbase.client.java.kv.DecrementOptions in project couchbase-jvm-clients by couchbase.

the class ReactiveBinaryCollection method decrement.

/**
 * Decrements the counter document by one or the number defined in the options.
 *
 * @param id the document id which is used to uniquely identify it.
 * @param options custom options to customize the decrement behavior.
 * @return a {@link CounterResult} once completed.
 * @throws DocumentNotFoundException the given document id is not found in the collection.
 * @throws TimeoutException if the operation times out before getting a result.
 * @throws CouchbaseException for all other error reasons (acts as a base type and catch-all).
 */
public Mono<CounterResult> decrement(final String id, final DecrementOptions options) {
    return Mono.defer(() -> {
        notNull(options, "DecrementOptions", () -> ReducedKeyValueErrorContext.create(id, async.collectionIdentifier()));
        DecrementOptions.Built opts = options.build();
        DecrementRequest request = async.decrementRequest(id, opts);
        return Reactor.wrap(request, CounterAccessor.decrement(core, request, id, opts.persistTo(), opts.replicateTo()), true);
    });
}
Also used : DecrementOptions(com.couchbase.client.java.kv.DecrementOptions) DecrementRequest(com.couchbase.client.core.msg.kv.DecrementRequest)

Aggregations

DecrementRequest (com.couchbase.client.core.msg.kv.DecrementRequest)1 DecrementOptions (com.couchbase.client.java.kv.DecrementOptions)1