/** * The field, modulo the given mod argument, is equal to the value * * @param field The field to compare * @param mod The modulo * @param value The value to compare to * @return the query */ public Q mod(String field, Number mod, Number value) { return put(field, QueryOperators.MOD, Arrays.asList(mod, value)); }
/** * The given field matches the regular expression * * @param field The field to comare * @param regex The regular expression to match with * @return the query */ public Q regex(String field, Pattern regex) { return put(field, null, regex); }
/** * The given field doesn't exist * * @param field The field to check * @return the query */ public Q notExists(String field) { return put(field, QueryOperators.EXISTS, false); }
/** * The field is not in the given set of values * * @param field The field to compare * @param values The value to compare to * @return the query */ public Q notIn(String field, Collection<?> values) { return put(field, QueryOperators.NIN, values); }
/** * The field is less than the given value * * @param field The field to compare * @param value The value to compare to * @return the query */ public Q lessThan(String field, Object value) { return put(field, QueryOperators.LT, value); }
/** * The field is equal to the given value * * @param field The field to compare * @param value The value to compare to * @return the query */ public Q is(String field, Object value) { return put(field, null, value); }
@Override protected DBCursor<T> putGroup(String op, Object... expressions) { checkExecuted(); Object[] serialized = new Object[expressions.length]; for (int i = 0; i < expressions.length; i++) { serialized[i] = jacksonDBCollection.serializeField(expressions[i]); } return super.putGroup(op, serialized); } }
/** * Execute the given JavaScript code as part of the query * * @param code the JavaScript code * @return the query */ public Q where(String code) { return put("$where", null, code); }
/** * The field is in the given set of values * * @param field The field to compare * @param values The value to compare to * @return the query */ public Q in(String field, Collection<?> values) { return put(field, QueryOperators.IN, values); }
/** * The field is greater than or equal to the given value * * @param field The field to compare * @param value The value to compare to * @return the query */ public Q greaterThanEquals(String field, Object value) { return put(field, QueryOperators.GTE, value); }
/** * The field is less than or equal to the given value * * @param field The field to compare * @param value The value to compare to * @return the query */ public Q lessThanEquals(String field, Object value) { return put(field, QueryOperators.LTE, value); }
/** * The array field is of the given size * * @param field The field to compare * @param size The value to compare * @return the query */ public Q size(String field, int size) { return put(field, QueryOperators.SIZE, size); }
/** * The field is not in the given set of values * * @param field The field to compare * @param values The value to compare to * @return the query */ public Q notIn(String field, Object... values) { return put(field, QueryOperators.NIN, values); }
/** * The field is not equal to the given value * * @param field The field to compare * @param value The value to compare to * @return the query */ public Q notEquals(String field, Object value) { return put(field, QueryOperators.NE, value); }
/** * The field is greater than the given value * * @param field The field to compare * @param value The value to compare to * @return the query */ public Q greaterThan(String field, Object value) { return put(field, QueryOperators.GT, value); }
/** * None of the given expressions matches * * @param expressions The expressions to test * @return the query */ public Q nor(Query... expressions) { return putGroup("$nor", expressions); }
/** * All of the given expressions matches * * @param expressions The expressions to test * @return the query */ public Q and(Query... expressions) { return putGroup("$and", expressions); }
/** * One of the given expressions matches * * @param expressions The expressions to test * @return the query */ public Q or(Query... expressions) { return putGroup("$or", expressions); }
/** * The given field doesn't exist * * @param field The field to check * @return the query */ public Q notExists(String field) { return put(field, QueryOperators.EXISTS, false); }
/** * The field is greater than the given value * * @param field The field to compare * @param value The value to compare to * @return the query */ public Q greaterThan(String field, Object value) { return put(field, QueryOperators.GT, value); }