use of com.couchbase.client.java.query.dsl.path.ReturningPath in project jans by JanssenProject.
the class CouchbaseOperationServiceImpl method deleteImpl.
private int deleteImpl(BucketMapping bucketMapping, String key, ScanConsistency scanConsistency, Expression expression, int count) throws DeleteException {
Bucket bucket = bucketMapping.getBucket();
Expression finalExpression = expression;
if (enableScopeSupport) {
Expression scopeExpression = Expression.path("META().id").like(Expression.s(key + "%"));
finalExpression = scopeExpression.and(expression);
}
MutateLimitPath deleteQuery = Delete.deleteFrom(Expression.i(bucketMapping.getBucketName())).where(finalExpression);
ReturningPath query = deleteQuery.limit(count);
LOG.debug("Execution query: '" + query + "'");
N1qlQueryResult result = bucket.query(N1qlQuery.simple(query, N1qlParams.build().consistency(scanConsistency)));
if (!result.finalSuccess()) {
throw new DeleteException(String.format("Failed to delete entries. Query: '%s'. Error: '%s', Error count: '%d'", query, result.errors(), result.info().errorCount()), result.errors().get(0).getInt("code"));
}
return result.info().mutationCount();
}
Aggregations