Search in sources :

Example 6 with RemoveOptions

use of com.couchbase.client.java.kv.RemoveOptions in project spring-data-couchbase by spring-projects.

the class CouchbaseTemplateQueryCollectionIntegrationTests method removeByIdOptions.

@Test
public void removeByIdOptions() {
    // 7 - options
    Airport saved = couchbaseTemplate.insertById(Airport.class).inScope(otherScope).inCollection(otherCollection).one(vie.withIcao("743"));
    RemoveOptions options = RemoveOptions.removeOptions().timeout(Duration.ofNanos(10));
    assertThrows(AmbiguousTimeoutException.class, () -> couchbaseTemplate.removeById().inScope(otherScope).inCollection(otherCollection).withOptions(options).one(vie.getId()));
}
Also used : Airport(org.springframework.data.couchbase.domain.Airport) RemoveOptions(com.couchbase.client.java.kv.RemoveOptions) Test(org.junit.jupiter.api.Test)

Example 7 with RemoveOptions

use of com.couchbase.client.java.kv.RemoveOptions in project spring-data-couchbase by spring-projects.

the class ReactiveCouchbaseTemplateQueryCollectionIntegrationTests method removeByIdOptions.

@Test
public void removeByIdOptions() {
    // 7 - options
    Airport saved = template.insertById(Airport.class).inScope(otherScope).inCollection(otherCollection).one(vie.withIcao("732")).block();
    RemoveOptions options = RemoveOptions.removeOptions().timeout(Duration.ofNanos(10));
    assertThrows(AmbiguousTimeoutException.class, () -> template.removeById().inScope(otherScope).inCollection(otherCollection).withOptions(options).one(vie.getId()).block());
}
Also used : Airport(org.springframework.data.couchbase.domain.Airport) RemoveOptions(com.couchbase.client.java.kv.RemoveOptions) Test(org.junit.jupiter.api.Test)

Example 8 with RemoveOptions

use of com.couchbase.client.java.kv.RemoveOptions in project spring-data-couchbase by spring-projects.

the class ReactiveCouchbaseTemplateQueryCollectionIntegrationTests method removeById.

@Test
public void removeById() {
    // 7
    RemoveOptions options = RemoveOptions.removeOptions().timeout(Duration.ofSeconds(10));
    Airport saved = template.insertById(Airport.class).inScope(scopeName).inCollection(collectionName).one(vie.withIcao("lowd")).block();
    RemoveResult removeResult = template.removeById().inScope(scopeName).inCollection(collectionName).withOptions(options).one(saved.getId()).block();
    assertEquals(saved.getId(), removeResult.getId());
}
Also used : RemoveResult(org.springframework.data.couchbase.core.RemoveResult) Airport(org.springframework.data.couchbase.domain.Airport) RemoveOptions(com.couchbase.client.java.kv.RemoveOptions) Test(org.junit.jupiter.api.Test)

Example 9 with RemoveOptions

use of com.couchbase.client.java.kv.RemoveOptions in project kafka-connect-couchbase by couchbase.

the class SinkAction method remove.

/**
 * Returns an action that removes the document from Couchbase if it exists.
 * Uses the document ID as the concurrency hint.
 */
public static SinkAction remove(SinkHandlerParams params, ReactiveCollection collection, String documentId) {
    RemoveOptions options = removeOptions();
    params.configureDurability(options);
    Mono<?> action = collection.remove(documentId, options).onErrorResume(DocumentNotFoundException.class, throwable -> Mono.empty());
    return new SinkAction(action, ConcurrencyHint.of(documentId));
}
Also used : RemoveOptions(com.couchbase.client.java.kv.RemoveOptions)

Aggregations

RemoveOptions (com.couchbase.client.java.kv.RemoveOptions)9 Test (org.junit.jupiter.api.Test)6 Airport (org.springframework.data.couchbase.domain.Airport)6 RemoveResult (org.springframework.data.couchbase.core.RemoveResult)2 RemoveRequest (com.couchbase.client.core.msg.kv.RemoveRequest)1 RetryStrategy (com.couchbase.client.core.retry.RetryStrategy)1 Duration (java.time.Duration)1