Search in sources :

Example 26 with QueryOptions

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

the class ReactiveCouchbaseTemplateQueryCollectionIntegrationTests method findByQueryOptions.

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

Example 27 with QueryOptions

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

the class ReactiveCouchbaseTemplateQueryCollectionIntegrationTests method findByQueryOther.

@Test
public void findByQueryOther() {
    // 4
    QueryOptions options = QueryOptions.queryOptions().timeout(Duration.ofSeconds(10));
    Airport saved = template.insertById(Airport.class).inScope(otherScope).inCollection(otherCollection).one(vie.withIcao("lowj")).block();
    try {
        List<Airport> found = template.findByQuery(Airport.class).withConsistency(QueryScanConsistency.REQUEST_PLUS).inScope(otherScope).inCollection(otherCollection).withOptions(options).all().collectList().block();
        assertEquals(saved.getId(), found.get(0).getId());
    } finally {
        template.removeById().inScope(otherScope).inCollection(otherCollection).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)

Example 28 with QueryOptions

use of com.couchbase.client.java.query.QueryOptions in project couchbase-jvm-clients by couchbase.

the class QueryIntegrationTest method reactiveSelect.

@Test
void reactiveSelect() {
    String id = insertDoc();
    QueryOptions options = queryOptions().scanConsistency(QueryScanConsistency.REQUEST_PLUS);
    Mono<ReactiveQueryResult> result = cluster.reactive().query("select * from " + bucketName + " where meta().id=\"" + id + "\"", options);
    List<JsonObject> rows = result.flux().flatMap(ReactiveQueryResult::rowsAsObject).collectList().block();
    assertNotNull(rows);
    assertEquals(1, rows.size());
}
Also used : ReactiveQueryResult(com.couchbase.client.java.query.ReactiveQueryResult) JsonObject(com.couchbase.client.java.json.JsonObject) QueryOptions(com.couchbase.client.java.query.QueryOptions) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 29 with QueryOptions

use of com.couchbase.client.java.query.QueryOptions in project couchbase-jvm-clients by couchbase.

the class QueryIntegrationTest method getProfileWhenRequested.

@Test
void getProfileWhenRequested() {
    String id = insertDoc();
    QueryOptions options = queryOptions().profile(QueryProfile.TIMINGS);
    QueryResult result = cluster.query("select * from " + bucketName + " where meta().id=\"" + id + "\"", options);
    JsonObject profile = result.metaData().profile().get();
    assertTrue(profile.size() > 0);
}
Also used : QueryResult(com.couchbase.client.java.query.QueryResult) ReactiveQueryResult(com.couchbase.client.java.query.ReactiveQueryResult) JsonObject(com.couchbase.client.java.json.JsonObject) QueryOptions(com.couchbase.client.java.query.QueryOptions) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 30 with QueryOptions

use of com.couchbase.client.java.query.QueryOptions in project couchbase-jvm-clients by couchbase.

the class QueryIntegrationTest method asyncPositionalParameterizedSelectQuery.

@Test
void asyncPositionalParameterizedSelectQuery() throws Exception {
    String id = insertDoc();
    QueryOptions options = queryOptions().scanConsistency(QueryScanConsistency.REQUEST_PLUS).parameters(JsonArray.from(id));
    CompletableFuture<QueryResult> result = cluster.async().query("select * from " + bucketName + " where meta().id=$1", options);
    List<JsonObject> rows = result.get().rowsAs(JsonObject.class);
    assertEquals(1, rows.size());
}
Also used : QueryResult(com.couchbase.client.java.query.QueryResult) ReactiveQueryResult(com.couchbase.client.java.query.ReactiveQueryResult) JsonObject(com.couchbase.client.java.json.JsonObject) QueryOptions(com.couchbase.client.java.query.QueryOptions) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) 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