private static Statement get(String bucket,
String[] documents,
int firstResult,
int maxResult,
Sort[] sorts,
Expression condition) {
boolean hasFistResult = firstResult > 0;
boolean hasMaxResult = maxResult > 0;
if (hasFistResult && hasMaxResult) {
return select(documents).from(i(bucket))
.where(condition)
.orderBy(sorts)
.limit(maxResult)
.offset(firstResult);
} else if (hasFistResult) {
return select(documents).from(i(bucket))
.where(condition)
.orderBy(sorts)
.offset(firstResult);
} else if (hasMaxResult) {
return select(documents).from(i(bucket)).where(condition)
.orderBy(sorts)
.limit(maxResult);
}
return select(documents).from(i(bucket)).where(condition).orderBy(sorts);
}