use of com.couchbase.client.java.query.dsl.Expression in project jnosql-diana-driver by eclipse.
the class QueryConverter method delete.
static QueryConverterResult delete(DocumentDeleteQuery query, String bucket) {
JsonObject params = JsonObject.create();
List<String> ids = new ArrayList<>();
Expression condition = getCondition(query.getCondition().orElseThrow(() -> new IllegalArgumentException("Condigtion is required")), params, ids, query.getDocumentCollection());
MutateLimitPath statement = null;
if (nonNull(condition)) {
statement = Delete.deleteFrom(bucket).where(condition);
}
return new QueryConverterResult(params, statement, ids);
}
use of com.couchbase.client.java.query.dsl.Expression in project jnosql-diana-driver by eclipse.
the class QueryConverter method select.
static QueryConverterResult select(DocumentQuery query, String bucket) {
JsonObject params = JsonObject.create();
List<String> keys = new ArrayList<>();
String[] documents = query.getDocuments().stream().toArray(String[]::new);
if (documents.length == 0) {
documents = ALL_SELECT;
}
Statement statement = null;
int firstResult = (int) query.getFirstResult();
int maxResult = (int) query.getMaxResults();
com.couchbase.client.java.query.dsl.Sort[] sorts = query.getSorts().stream().map(SORT_MAP).toArray(com.couchbase.client.java.query.dsl.Sort[]::new);
if (query.getCondition().isPresent()) {
Expression condition = getCondition(query.getCondition().get(), params, keys, query.getDocumentCollection());
if (nonNull(condition)) {
statement = create(bucket, documents, firstResult, maxResult, sorts, condition);
} else {
statement = null;
}
} else {
statement = create(bucket, documents, firstResult, maxResult, sorts);
}
return new QueryConverterResult(params, statement, keys);
}
Aggregations