/** * Creates a new {@link N1qlQuery} for the given class, this method build a query like: * * <pre> * select b.* from bucket b where b._class = 'model.Beer' * </pre> * * @param bucket Bucket name. * @param entityClass Entity class. * @return A query. */ public static GroupByPath from(final String bucket, final Class<?> entityClass) { String alias = String.valueOf(entityClass.getSimpleName().charAt(0)); return Select.select(alias + ".*") .from(i(bucket) + " " + alias) .where(path(alias, CLASS).eq(s(entityClass.getName()))); }
exp = x(colName).lt(x(val)); break; case "<=": exp = x(colName).lte(x(val)); break; case ">": exp = x(colName).gt(x(val)); break; case ">=": exp = x(colName).gte(x(val)); break; case "=": exp = x(colName).eq(x(val)); break; default: return asPath.where(exp.and(x(CouchbaseConstants.KUNDERA_ENTITY).eq(x("'" + tableName) + "'")));
/** * Returned expression results in new array of numbers, from start until the largest number less than end. * Successive numbers are incremented by step. If step is omitted, the default is 1. If step is negative, * decrements until the smallest number greater than end. */ public static Expression arrayRange(long start, long end, long step) { return x("ARRAY_RANGE(" + start + ", " + end + ", " + step + ")"); }
@Override public String export() { return "INSERT INTO " + bucket.toString(); } });
/** * Returned expression results in the first position of value within the array, or -1. * Array position is zero-based, i.e. the first position is 0. */ public static Expression arrayPosition(Expression expression, Expression value) { return x("ARRAY_POSITION(" + expression.toString() + ", " + value.toString() + ")"); }
@Override public String export() { return "UPSERT INTO " + bucket.toString(); } });
/** * Returned expression results in a substring from the integer position to the end of the string. * * The position is zero-based, i.e. the first position is 0. * If position is negative, it is counted from the end of the string; -1 is the last position in the string. */ public static Expression substr(Expression expression, int position) { return x("SUBSTR(" + expression.toString() + ", " + position + ")"); }