Search in sources :

Example 1 with ReactiveQueryResult

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

the class QueryIntegrationTest method reactivePositionalParameterizedSelectQuery.

@Test
void reactivePositionalParameterizedSelectQuery() {
    String id = insertDoc();
    QueryOptions options = queryOptions().scanConsistency(QueryScanConsistency.REQUEST_PLUS).parameters(JsonArray.from(id));
    Mono<ReactiveQueryResult> result = cluster.reactive().query("select * from " + bucketName + " where meta().id=$1", 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 2 with ReactiveQueryResult

use of com.couchbase.client.java.query.ReactiveQueryResult 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 3 with ReactiveQueryResult

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

the class QueryCollectionIntegrationTest method performsAdhocQuery.

@Test
void performsAdhocQuery() {
    Scope scope = cluster.bucket(config().bucketname()).scope(SCOPE_NAME);
    Collection collection = scope.collection(COLLECTION_NAME);
    String id = insertDoc(collection);
    QueryOptions options = queryOptions().scanConsistency(QueryScanConsistency.REQUEST_PLUS);
    QueryResult result = scope.query("select * from `" + COLLECTION_NAME + "` where meta().id=\"" + id + "\"", options);
    assertEquals(QueryStatus.SUCCESS, result.metaData().status());
    assertEquals(1, result.rowsAsObject().size());
    ReactiveScope reactiveScope = cluster.bucket(config().bucketname()).reactive().scope(SCOPE_NAME);
    ReactiveQueryResult reactiveResult = reactiveScope.query("select * from `" + COLLECTION_NAME + "` where meta().id=\"" + id + "\"", options).block();
    assertEquals(QueryStatus.SUCCESS, reactiveResult.metaData().block().status());
    assertEquals(1, reactiveResult.rowsAsObject().blockLast().size());
}
Also used : QueryResult(com.couchbase.client.java.query.QueryResult) ReactiveQueryResult(com.couchbase.client.java.query.ReactiveQueryResult) ReactiveQueryResult(com.couchbase.client.java.query.ReactiveQueryResult) QueryOptions(com.couchbase.client.java.query.QueryOptions) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 4 with ReactiveQueryResult

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

the class QueryIntegrationTest method reactiveNamedParameterizedSelectQuery.

@Test
void reactiveNamedParameterizedSelectQuery() {
    String id = insertDoc();
    QueryOptions options = queryOptions().scanConsistency(QueryScanConsistency.REQUEST_PLUS).parameters(JsonObject.create().put("id", id));
    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)

Aggregations

QueryOptions (com.couchbase.client.java.query.QueryOptions)4 ReactiveQueryResult (com.couchbase.client.java.query.ReactiveQueryResult)4 JavaIntegrationTest (com.couchbase.client.java.util.JavaIntegrationTest)4 Test (org.junit.jupiter.api.Test)4 JsonObject (com.couchbase.client.java.json.JsonObject)3 QueryResult (com.couchbase.client.java.query.QueryResult)1