use of com.couchbase.client.java.query.QueryOptions in project couchbase-jvm-clients by couchbase.
the class QueryIntegrationTest method asyncNamedParameterizedSelectQuery.
@Test
void asyncNamedParameterizedSelectQuery() throws Exception {
String id = insertDoc();
QueryOptions options = queryOptions().scanConsistency(QueryScanConsistency.REQUEST_PLUS).parameters(JsonObject.create().put("id", id));
CompletableFuture<QueryResult> result = cluster.async().query("select * from " + bucketName + " where meta().id=$id", options);
List<JsonObject> rows = result.get().rowsAs(JsonObject.class);
assertEquals(1, rows.size());
}
use of com.couchbase.client.java.query.QueryOptions in project couchbase-jvm-clients by couchbase.
the class QueryIntegrationTest method readOnlyViolation.
@Test
void readOnlyViolation() {
QueryOptions options = queryOptions().readonly(true);
CouchbaseException e = assertThrows(CouchbaseException.class, () -> cluster.query("INSERT INTO " + bucketName + " (KEY, VALUE) values (\"foo\", \"bar\")", options));
assertEquals(1000, ((QueryErrorContext) e.context()).errors().get(0).code());
}
use of com.couchbase.client.java.query.QueryOptions in project couchbase-jvm-clients by couchbase.
the class QueryIntegrationTest method asyncSelect.
@Test
void asyncSelect() throws Exception {
String id = insertDoc();
QueryOptions options = queryOptions().scanConsistency(QueryScanConsistency.REQUEST_PLUS);
CompletableFuture<QueryResult> result = cluster.async().query("select * from " + bucketName + " where meta().id=\"" + id + "\"", options);
List<JsonObject> rows = result.get().rowsAs(JsonObject.class);
assertEquals(1, rows.size());
}
use of com.couchbase.client.java.query.QueryOptions in project spring-data-couchbase by spring-projects.
the class CouchbaseTemplateQueryCollectionIntegrationTests method removeByQuery.
@Test
public void removeByQuery() {
// 8
QueryOptions options = QueryOptions.queryOptions().timeout(Duration.ofSeconds(10));
Airport saved = couchbaseTemplate.insertById(Airport.class).inScope(scopeName).inCollection(collectionName).one(vie.withIcao("495"));
List<RemoveResult> removeResults = couchbaseTemplate.removeByQuery(Airport.class).withConsistency(QueryScanConsistency.REQUEST_PLUS).inScope(scopeName).inCollection(collectionName).withOptions(options).matching(Query.query(QueryCriteria.where("iata").is(vie.getIata()))).all();
assertEquals(saved.getId(), removeResults.get(0).getId());
}
use of com.couchbase.client.java.query.QueryOptions in project spring-data-couchbase by spring-projects.
the class CouchbaseTemplateQueryCollectionIntegrationTests method removeByQueryOptions.
@Test
public void removeByQueryOptions() {
// 8 - options
QueryOptions options = QueryOptions.queryOptions().timeout(Duration.ofNanos(10));
assertThrows(AmbiguousTimeoutException.class, () -> couchbaseTemplate.removeByQuery(Airport.class).withConsistency(QueryScanConsistency.REQUEST_PLUS).inScope(otherScope).inCollection(otherCollection).withOptions(options).matching(Query.query(QueryCriteria.where("iata").is(vie.getIata()))).all());
}
Aggregations