Search in sources :

Example 16 with QueryOptions

use of com.couchbase.client.java.query.QueryOptions in project spring-data-couchbase by spring-projects.

the class CouchbaseTemplateQueryCollectionIntegrationTests method findByQueryOptions.

@Test
public void findByQueryOptions() {
    // 4
    QueryOptions options = QueryOptions.queryOptions().timeout(Duration.ofNanos(10));
    assertThrows(AmbiguousTimeoutException.class, () -> couchbaseTemplate.findByQuery(Airport.class).withConsistency(QueryScanConsistency.REQUEST_PLUS).inScope(otherScope).inCollection(otherCollection).withOptions(options).all());
}
Also used : QueryOptions(com.couchbase.client.java.query.QueryOptions) Test(org.junit.jupiter.api.Test)

Example 17 with QueryOptions

use of com.couchbase.client.java.query.QueryOptions in project spring-data-couchbase by spring-projects.

the class JavaIntegrationTests method toQueryOptions.

private static QueryOptions toQueryOptions(CommonOptions<?>.BuiltCommonOptions options) {
    QueryOptions result = QueryOptions.queryOptions();
    options.timeout().ifPresent(result::timeout);
    options.retryStrategy().ifPresent(result::retryStrategy);
    return result;
}
Also used : QueryOptions(com.couchbase.client.java.query.QueryOptions)

Example 18 with QueryOptions

use of com.couchbase.client.java.query.QueryOptions in project spring-data-couchbase by spring-projects.

the class ReactiveCouchbaseTemplateQueryCollectionIntegrationTests method removeByQuery.

@Test
public void removeByQuery() {
    // 8
    QueryOptions options = QueryOptions.queryOptions().timeout(Duration.ofSeconds(10));
    Airport saved = template.insertById(Airport.class).inScope(scopeName).inCollection(collectionName).one(vie.withIcao("lowe")).block();
    List<RemoveResult> removeResults = template.removeByQuery(Airport.class).withConsistency(QueryScanConsistency.REQUEST_PLUS).inScope(scopeName).inCollection(collectionName).withOptions(options).matching(Query.query(QueryCriteria.where("iata").is(vie.getIata()))).all().collectList().block();
    assertEquals(saved.getId(), removeResults.get(0).getId());
}
Also used : RemoveResult(org.springframework.data.couchbase.core.RemoveResult) Airport(org.springframework.data.couchbase.domain.Airport) QueryOptions(com.couchbase.client.java.query.QueryOptions) Test(org.junit.jupiter.api.Test)

Example 19 with QueryOptions

use of com.couchbase.client.java.query.QueryOptions in project spring-data-couchbase by spring-projects.

the class ReactiveCouchbaseTemplateQueryCollectionIntegrationTests method removeByQueryOther.

@Test
public void removeByQueryOther() {
    // 8
    QueryOptions options = QueryOptions.queryOptions().timeout(Duration.ofSeconds(10));
    Airport saved = template.insertById(Airport.class).inScope(otherScope).inCollection(otherCollection).one(vie.withIcao("lown")).block();
    List<RemoveResult> removeResults = template.removeByQuery(Airport.class).withConsistency(QueryScanConsistency.REQUEST_PLUS).inScope(otherScope).inCollection(otherCollection).withOptions(options).matching(Query.query(QueryCriteria.where("iata").is(vie.getIata()))).all().collectList().block();
    assertEquals(saved.getId(), removeResults.get(0).getId());
}
Also used : RemoveResult(org.springframework.data.couchbase.core.RemoveResult) Airport(org.springframework.data.couchbase.domain.Airport) QueryOptions(com.couchbase.client.java.query.QueryOptions) Test(org.junit.jupiter.api.Test)

Example 20 with QueryOptions

use of com.couchbase.client.java.query.QueryOptions in project spring-data-couchbase by spring-projects.

the class ReactiveCouchbaseTemplateQueryCollectionIntegrationTests method findByQuery.

@Test
public void findByQuery() {
    // 4
    QueryOptions options = QueryOptions.queryOptions().timeout(Duration.ofSeconds(10));
    Airport saved = template.insertById(Airport.class).inScope(scopeName).inCollection(collectionName).one(vie.withIcao("lowa")).block();
    try {
        List<Airport> found = template.findByQuery(Airport.class).withConsistency(QueryScanConsistency.REQUEST_PLUS).inScope(scopeName).inCollection(collectionName).withOptions(options).all().collectList().block();
        assertEquals(saved.getId(), found.get(0).getId());
    } finally {
        template.removeById().inScope(scopeName).inCollection(collectionName).one(saved.getId()).block();
    }
}
Also used : Airport(org.springframework.data.couchbase.domain.Airport) QueryOptions(com.couchbase.client.java.query.QueryOptions) Test(org.junit.jupiter.api.Test)

Aggregations

QueryOptions (com.couchbase.client.java.query.QueryOptions)40 Test (org.junit.jupiter.api.Test)31 JavaIntegrationTest (com.couchbase.client.java.util.JavaIntegrationTest)19 ReactiveQueryResult (com.couchbase.client.java.query.ReactiveQueryResult)18 QueryResult (com.couchbase.client.java.query.QueryResult)16 JsonObject (com.couchbase.client.java.json.JsonObject)15 Airport (org.springframework.data.couchbase.domain.Airport)10 ReducedQueryErrorContext (com.couchbase.client.core.error.context.ReducedQueryErrorContext)4 JsonSerializer (com.couchbase.client.java.codec.JsonSerializer)4 CouchbaseException (com.couchbase.client.core.error.CouchbaseException)2 JsonArray (com.couchbase.client.java.json.JsonArray)2 MutationResult (com.couchbase.client.java.kv.MutationResult)2 Duration (java.time.Duration)2 RemoveResult (org.springframework.data.couchbase.core.RemoveResult)2 Reactor (com.couchbase.client.core.Reactor)1 Stability (com.couchbase.client.core.annotation.Stability)1 RequestSpan (com.couchbase.client.core.cnc.RequestSpan)1 TracingIdentifiers (com.couchbase.client.core.cnc.TracingIdentifiers)1 IndexExistsException (com.couchbase.client.core.error.IndexExistsException)1 IndexFailureException (com.couchbase.client.core.error.IndexFailureException)1