Search in sources :

Example 1 with PrependOptions

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

the class ReactiveBinaryCollection method prepend.

/**
 * Prepends binary content to the document with custom options.
 *
 * @param id the document id which is used to uniquely identify it.
 * @param content the binary content to append to the document.
 * @param options custom options to customize the prepend behavior.
 * @return a {@link MutationResult} once completed.
 * @throws DocumentNotFoundException the given document id is not found in the collection.
 * @throws CasMismatchException if the document has been concurrently modified on the server.
 * @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<MutationResult> prepend(final String id, final byte[] content, final PrependOptions options) {
    return Mono.defer(() -> {
        notNull(options, "PrependOptions", () -> ReducedKeyValueErrorContext.create(id, async.collectionIdentifier()));
        PrependOptions.Built opts = options.build();
        PrependRequest request = async.prependRequest(id, content, opts);
        return Reactor.wrap(request, PrependAccessor.prepend(core, request, id, opts.persistTo(), opts.replicateTo()), true);
    });
}
Also used : PrependOptions(com.couchbase.client.java.kv.PrependOptions) PrependRequest(com.couchbase.client.core.msg.kv.PrependRequest)

Aggregations

PrependRequest (com.couchbase.client.core.msg.kv.PrependRequest)1 PrependOptions (com.couchbase.client.java.kv.PrependOptions)1