use of com.couchbase.client.java.kv.RemoveOptions in project couchbase-jvm-clients by couchbase.
the class ReactiveCollection method remove.
/**
* Removes a Document from a collection with custom options.
*
* @param id the id of the document to remove.
* @param options custom options to change the default behavior.
* @return a {@link Mono} completing once removed or failed.
*/
public Mono<MutationResult> remove(final String id, final RemoveOptions options) {
return Mono.defer(() -> {
notNull(options, "RemoveOptions", () -> ReducedKeyValueErrorContext.create(id, asyncCollection.collectionIdentifier()));
RemoveOptions.Built opts = options.build();
RemoveRequest request = asyncCollection.removeRequest(id, opts);
return Reactor.wrap(request, RemoveAccessor.remove(core, request, id, opts.persistTo(), opts.replicateTo()), true);
});
}
use of com.couchbase.client.java.kv.RemoveOptions in project spring-data-couchbase by spring-projects.
the class CouchbaseTemplateQueryCollectionIntegrationTests method removeByIdOther.
@Test
public void removeByIdOther() {
// 7
RemoveOptions options = RemoveOptions.removeOptions().timeout(Duration.ofSeconds(10));
Airport saved = couchbaseTemplate.insertById(Airport.class).inScope(otherScope).inCollection(otherCollection).one(vie.withIcao("638"));
RemoveResult removeResult = couchbaseTemplate.removeById().inScope(otherScope).inCollection(otherCollection).withOptions(options).one(saved.getId());
assertEquals(saved.getId(), removeResult.getId());
}
use of com.couchbase.client.java.kv.RemoveOptions in project spring-data-couchbase by spring-projects.
the class OptionsBuilder method buildRemoveOptions.
public static RemoveOptions buildRemoveOptions(RemoveOptions options, PersistTo persistTo, ReplicateTo replicateTo, DurabilityLevel durabilityLevel, Long cas) {
options = options != null ? options : RemoveOptions.removeOptions();
if (persistTo != PersistTo.NONE || replicateTo != ReplicateTo.NONE) {
options.durability(persistTo, replicateTo);
} else if (durabilityLevel != DurabilityLevel.NONE) {
options.durability(durabilityLevel);
}
RemoveOptions.Built optsBuilt = options.build();
Duration timeout = fromFirst(Duration.ofSeconds(0), optsBuilt.timeout());
RetryStrategy retryStrategy = fromFirst(null, optsBuilt.retryStrategy());
if (timeout != null) {
options.timeout(timeout);
}
if (retryStrategy != null) {
options.retryStrategy(retryStrategy);
}
if (cas != null) {
options.cas(cas);
}
if (LOG.isTraceEnabled()) {
LOG.trace("remove options: {}" + toString(options));
}
return options;
}
use of com.couchbase.client.java.kv.RemoveOptions in project spring-data-couchbase by spring-projects.
the class ReactiveCouchbaseTemplateQueryCollectionIntegrationTests method removeByIdOther.
@Test
public void removeByIdOther() {
// 7
RemoveOptions options = RemoveOptions.removeOptions().timeout(Duration.ofSeconds(10));
Airport saved = template.insertById(Airport.class).inScope(otherScope).inCollection(otherCollection).one(vie.withIcao("lowm")).block();
RemoveResult removeResult = template.removeById().inScope(otherScope).inCollection(otherCollection).withOptions(options).one(saved.getId()).block();
assertEquals(saved.getId(), removeResult.getId());
}
use of com.couchbase.client.java.kv.RemoveOptions in project spring-data-couchbase by spring-projects.
the class CouchbaseTemplateQueryCollectionIntegrationTests method removeById.
@Test
public void removeById() {
// 7
RemoveOptions options = RemoveOptions.removeOptions().timeout(Duration.ofSeconds(10));
Airport saved = couchbaseTemplate.insertById(Airport.class).inScope(scopeName).inCollection(collectionName).one(vie.withIcao("485"));
RemoveResult removeResult = couchbaseTemplate.removeById().inScope(scopeName).inCollection(collectionName).withOptions(options).one(saved.getId());
assertEquals(saved.getId(), removeResult.getId());
}
Aggregations