use of com.couchbase.client.java.query.QueryOptions in project couchbase-jvm-clients by couchbase.
the class AsyncQueryIndexManager method toQueryOptions.
private static QueryOptions toQueryOptions(CommonOptions<?>.BuiltCommonOptions options) {
QueryOptions result = QueryOptions.queryOptions();
options.timeout().ifPresent(result::timeout);
options.retryStrategy().ifPresent(result::retryStrategy);
result.clientContext(options.clientContext());
return result;
}
use of com.couchbase.client.java.query.QueryOptions in project couchbase-jvm-clients by couchbase.
the class AsyncScope method query.
/**
* Performs a N1QL query with custom {@link QueryOptions} in a Scope.
*
* @param statement the N1QL query statement as a raw string.
* @param options the custom options for this query.
* @return the {@link QueryResult} once the response arrives successfully.
*/
public CompletableFuture<QueryResult> query(final String statement, final QueryOptions options) {
notNull(options, "QueryOptions", () -> new ReducedQueryErrorContext(statement));
final QueryOptions.Built opts = options.build();
JsonSerializer serializer = opts.serializer() == null ? environment.jsonSerializer() : opts.serializer();
return queryAccessor.queryAsync(queryRequest(bucketName(), scopeName, statement, opts, core, environment()), opts, serializer);
}
use of com.couchbase.client.java.query.QueryOptions in project couchbase-jvm-clients by couchbase.
the class ReactiveScope method query.
/**
* Performs a N1QL query with custom {@link QueryOptions} in a Scope
*
* @param statement the N1QL query statement as a raw string.
* @param options the custom options for this query.
* @return the {@link ReactiveQueryResult} once the response arrives successfully.
*/
public Mono<ReactiveQueryResult> query(final String statement, final QueryOptions options) {
notNull(options, "QueryOptions", () -> new ReducedQueryErrorContext(statement));
final QueryOptions.Built opts = options.build();
JsonSerializer serializer = opts.serializer() == null ? environment().jsonSerializer() : opts.serializer();
return Mono.defer(() -> {
return async().queryAccessor().queryReactive(async().queryRequest(bucketName(), name(), statement, opts, core(), environment()), opts, serializer);
});
}
use of com.couchbase.client.java.query.QueryOptions in project couchbase-jvm-clients by couchbase.
the class ReactiveCluster method query.
/**
* Performs a N1QL query with custom {@link QueryOptions}.
*
* @param statement the N1QL query statement as a raw string.
* @param options the custom options for this query.
* @return the {@link ReactiveQueryResult} once the response arrives successfully.
*/
public Mono<ReactiveQueryResult> query(final String statement, final QueryOptions options) {
notNull(options, "QueryOptions", () -> new ReducedQueryErrorContext(statement));
final QueryOptions.Built opts = options.build();
JsonSerializer serializer = opts.serializer() == null ? environment().jsonSerializer() : opts.serializer();
return Mono.defer(() -> {
return asyncCluster.queryAccessor().queryReactive(asyncCluster.queryRequest(statement, opts), opts, serializer);
});
}
use of com.couchbase.client.java.query.QueryOptions in project couchbase-jvm-clients by couchbase.
the class QueryCollectionIntegrationTest method consistentWith.
// Test for MB-46876
@Test
void consistentWith() {
String id = UUID.randomUUID().toString();
Scope scope = cluster.bucket(config().bucketname()).scope(SCOPE_NAME);
Collection collection = scope.collection(COLLECTION_NAME);
MutationResult mr = collection.insert(id, FOO_CONTENT);
QueryOptions options = queryOptions().consistentWith(MutationState.from(mr.mutationToken().get())).parameters(JsonArray.from(id));
QueryResult result = scope.query("select * from `" + COLLECTION_NAME + "` where meta().id=$1", options);
List<JsonObject> rows = result.rowsAs(JsonObject.class);
assertEquals(1, rows.size());
assertEquals(FOO_CONTENT, rows.get(0).getObject(COLLECTION_NAME));
}
Aggregations