use of com.couchbase.client.java.kv.ExistsOptions in project couchbase-jvm-clients by couchbase.
the class AsyncCollection method existsRequest.
/**
* Helper method to create the exists request from its options.
*
* @param id the document ID
* @param options custom options to change the default behavior
* @return the observe request used for exists.
*/
GetMetaRequest existsRequest(final String id, final ExistsOptions options) {
notNullOrEmpty(id, "Id", () -> ReducedKeyValueErrorContext.create(id, collectionIdentifier));
notNull(options, "ExistsOptions", () -> ReducedKeyValueErrorContext.create(id, collectionIdentifier));
ExistsOptions.Built opts = options.build();
Duration timeout = opts.timeout().orElse(environment.timeoutConfig().kvTimeout());
RetryStrategy retryStrategy = opts.retryStrategy().orElse(environment.retryStrategy());
RequestSpan span = environment.requestTracer().requestSpan(TracingIdentifiers.SPAN_REQUEST_KV_EXISTS, opts.parentSpan().orElse(null));
GetMetaRequest request = new GetMetaRequest(id, timeout, coreContext, collectionIdentifier, retryStrategy, span);
request.context().clientContext(opts.clientContext());
return request;
}
use of com.couchbase.client.java.kv.ExistsOptions in project spring-data-couchbase by spring-projects.
the class CouchbaseTemplateQueryCollectionIntegrationTests method existsById.
/**
* find . -name 'Exec*OperationSupport.java'|awk -F/ '{print $NF}'|sort| awk -F. '{print "* ", NR, ")",$1, ""}'<br>
* 1) ExecutableExistsByIdOperationSupport <br>
* 2) ExecutableFindByAnalyticsOperationSupport <br>
* 3) ExecutableFindByIdOperationSupport <br>
* 4) ExecutableFindByQueryOperationSupport <br>
* 5) ExecutableFindFromReplicasByIdOperationSupport <br>
* 6) ExecutableInsertByIdOperationSupport <br>
* 7) ExecutableRemoveByIdOperationSupport <br>
* 8) ExecutableRemoveByQueryOperationSupport <br>
* 9) ExecutableReplaceByIdOperationSupport <br>
* 10)ExecutableUpsertByIdOperationSupport <br>
*/
@Test
public void existsById() {
// 1
GetOptions options = GetOptions.getOptions().timeout(Duration.ofSeconds(10));
ExistsOptions existsOptions = ExistsOptions.existsOptions().timeout(Duration.ofSeconds(10));
Airport saved = couchbaseTemplate.insertById(Airport.class).inScope(scopeName).inCollection(collectionName).one(vie.withIcao("398"));
try {
Boolean exists = couchbaseTemplate.existsById().inScope(scopeName).inCollection(collectionName).withOptions(existsOptions).one(saved.getId());
assertTrue(exists, "Airport should exist: " + saved.getId());
} finally {
couchbaseTemplate.removeById().inScope(scopeName).inCollection(collectionName).one(saved.getId());
}
}
use of com.couchbase.client.java.kv.ExistsOptions in project spring-data-couchbase by spring-projects.
the class CouchbaseTemplateQueryCollectionIntegrationTests method existsByIdOptions.
@Test
public void existsByIdOptions() {
// 1 - Options
ExistsOptions options = ExistsOptions.existsOptions().timeout(Duration.ofNanos(10));
assertThrows(UnambiguousTimeoutException.class, () -> couchbaseTemplate.existsById().inScope(otherScope).inCollection(otherCollection).withOptions(options).one(vie.getId()));
}
use of com.couchbase.client.java.kv.ExistsOptions in project spring-data-couchbase by spring-projects.
the class ReactiveCouchbaseTemplateQueryCollectionIntegrationTests method existsById.
/**
* find . -name 'Exec*OperationSupport.java'|awk -F/ '{print $NF}'|sort| awk -F. '{print "* ", NR, ")",$1, ""}'<br>
* 1) ExecutableExistsByIdOperationSupport <br>
* 2) ExecutableFindByAnalyticsOperationSupport <br>
* 3) ExecutableFindByIdOperationSupport <br>
* 4) ExecutableFindByQueryOperationSupport <br>
* 5) ExecutableFindFromReplicasByIdOperationSupport <br>
* 6) ExecutableInsertByIdOperationSupport <br>
* 7) ExecutableRemoveByIdOperationSupport <br>
* 8) ExecutableRemoveByQueryOperationSupport <br>
* 9) ExecutableReplaceByIdOperationSupport <br>
* 10)ExecutableUpsertByIdOperationSupport <br>
*/
@Test
public void existsById() {
// 1
GetOptions options = GetOptions.getOptions().timeout(Duration.ofSeconds(10));
ExistsOptions existsOptions = ExistsOptions.existsOptions().timeout(Duration.ofSeconds(10));
Airport saved = template.insertById(Airport.class).inScope(scopeName).inCollection(collectionName).one(vie.withIcao("low7")).block();
try {
Boolean exists = template.existsById().inScope(scopeName).inCollection(collectionName).withOptions(existsOptions).one(saved.getId()).block();
assertTrue(exists, "Airport should exist: " + saved.getId());
} finally {
template.removeById().inScope(scopeName).inCollection(collectionName).one(saved.getId()).block();
}
}
use of com.couchbase.client.java.kv.ExistsOptions in project spring-data-couchbase by spring-projects.
the class CouchbaseTemplateQueryCollectionIntegrationTests method existsByIdOther.
@Test
public void existsByIdOther() {
// 1
GetOptions options = GetOptions.getOptions().timeout(Duration.ofSeconds(10));
ExistsOptions existsOptions = ExistsOptions.existsOptions().timeout(Duration.ofSeconds(10));
Airport saved = couchbaseTemplate.insertById(Airport.class).inScope(otherScope).inCollection(otherCollection).one(vie.withIcao("lowg"));
try {
Boolean exists = couchbaseTemplate.existsById().inScope(otherScope).inCollection(otherCollection).withOptions(existsOptions).one(vie.getId());
assertTrue(exists, "Airport should exist: " + vie.getId());
} finally {
couchbaseTemplate.removeById().inScope(otherScope).inCollection(otherCollection).one(vie.getId());
}
}
Aggregations