public class Query extends Object
This class provides a constructor used to create a Query instance,
which is used to query data matching specified conditions in the database.
This class also provides methods for adding predicates to the Query instance.
SystemCapability.Data#DATA_DISTRIBUTEDDATAMGR| 限定符和类型 | 方法 | 说明 |
|---|---|---|
Query |
and() |
Constructs a
Query object with the and condition. |
Query |
beginGroup() |
Creates a query condition group with a left bracket.
|
Query |
endGroup() |
Creates a query condition group with a right bracket.
|
Query |
equalTo(String field,
boolean value) |
Constructs a
Query object to query entries with the specified field whose value is equal
to the specified boolean value. |
Query |
equalTo(String field,
double value) |
Constructs a
Query object to query entries with the specified field whose value is equal
to the specified double value. |
Query |
equalTo(String field,
int value) |
Constructs a
Query object to query entries with the specified field whose value is equal
to the specified int value. |
Query |
equalTo(String field,
long value) |
Constructs a
Query object to query entries with the specified field whose value is equal
to the specified long value. |
Query |
equalTo(String field,
String value) |
Constructs a
Query object to query entries with the specified field whose value is equal
to the specified string value. |
Query |
greaterThan(String field,
double value) |
Constructs a
Query object to query entries with the specified field whose value is
greater than the specified double value. |
Query |
greaterThan(String field,
int value) |
Constructs a
Query object to query entries with the specified field whose value is
greater than the specified int value. |
Query |
greaterThan(String field,
long value) |
Constructs a
Query object to query entries with the specified field whose value is
greater than the specified long value. |
Query |
greaterThan(String field,
String value) |
Constructs a
Query object to query entries with the specified field whose value is
greater than the specified string value. |
Query |
greaterThanOrEqualTo(String field,
double value) |
Constructs a
Query object to query entries with the specified field whose value is greater
than or equal to the specified double value. |
Query |
greaterThanOrEqualTo(String field,
int value) |
Constructs a
Query object to query entries with the specified field whose value is greater
than or equal to the specified int value. |
Query |
greaterThanOrEqualTo(String field,
long value) |
Constructs a
Query object to query entries with the specified field whose value is greater
than or equal to the specified long value. |
Query |
greaterThanOrEqualTo(String field,
String value) |
Constructs a
Query object to query entries with the specified field whose value is greater
than or equal to the specified string value. |
Query |
inDouble(String field,
List<Double> valueList) |
Constructs a
Query object to query entries with the specified field whose value is within
the specified double value list. |
Query |
inInt(String field,
List<Integer> valueList) |
Constructs a
Query object to query entries with the specified field whose value is within
the specified int value list. |
Query |
inLong(String field,
List<Long> valueList) |
Constructs a
Query object to query entries with the specified field whose value is within
the specified long value list. |
Query |
inString(String field,
List<String> valueList) |
Constructs a
Query object to query entries with the specified field whose value is within
the specified string value list. |
Query |
isNotNull(String field) |
Creates a query condition with a specified field that is not null.
|
Query |
isNull(String field) |
Constructs a
Query object to query entries with the specified field whose value is null. |
Query |
lessThan(String field,
double value) |
Constructs a
Query object to query entries with the specified field whose value is less
than the specified double value. |
Query |
lessThan(String field,
int value) |
Constructs a
Query object to query entries with the specified field whose value is
less than the specified int value. |
Query |
lessThan(String field,
long value) |
Constructs a
Query object to query entries with the specified field whose value is less
than the specified long value. |
Query |
lessThan(String field,
String value) |
Constructs a
Query object to query entries with the specified field whose value is less
than the specified string value. |
Query |
lessThanOrEqualTo(String field,
double value) |
Constructs a
Query object to query entries with the specified field whose value is less
than or equal to the specified double value. |
Query |
lessThanOrEqualTo(String field,
int value) |
Constructs a
Query object to query entries with the specified field whose value is less
than or equal to the specified int value. |
Query |
lessThanOrEqualTo(String field,
long value) |
Constructs a
Query object to query entries with the specified field whose value is less
than or equal to the specified long value. |
Query |
lessThanOrEqualTo(String field,
String value) |
Constructs a
Query object to query entries with the specified field whose value is less than or
equal to the specified string value. |
Query |
like(String field,
String value) |
Constructs a
Query object to query entries with the specified field whose value is similar
to the specified string value. |
Query |
limit(int number,
int offset) |
Constructs a
Query object to specify the number of results and the start position. |
Query |
notEqualTo(String field,
boolean value) |
Constructs a
Query object to query entries with the specified field whose value is
not equal to the specified boolean value. |
Query |
notEqualTo(String field,
double value) |
Constructs a
Query object to query entries with the specified field whose value
is not equal to the specified double value. |
Query |
notEqualTo(String field,
int value) |
Constructs a
Query object to query entries with the specified field whose value is
not equal to the specified int value. |
Query |
notEqualTo(String field,
long value) |
Constructs a
Query object to query entries with the specified field whose value
is not equal to the specified long value. |
Query |
notEqualTo(String field,
String value) |
Constructs a
Query object to query entries with the specified field whose value is
not equal to the specified string value. |
Query |
notInDouble(String field,
List<Double> valueList) |
Constructs a
Query object to query entries with the specified field whose value is not within
the specified double value list. |
Query |
notInInt(String field,
List<Integer> valueList) |
Constructs a
Query object to query entries with the specified field whose value is not within
the specified int value list. |
Query |
notInLong(String field,
List<Long> valueList) |
Constructs a
Query object to query entries with the specified field whose value is not within
the specified long value list. |
Query |
notInString(String field,
List<String> valueList) |
Constructs a
Query object to query entries with the specified field whose value is not within
the specified string value list. |
Query |
or() |
Constructs a
Query object with the or condition. |
Query |
orderByAsc(String field) |
Constructs a
Query object to sort the query results in ascending order. |
Query |
orderByDesc(String field) |
Constructs a
Query object to sort the query results in descending order. |
Query |
prefixKey(String prefix) |
Creates a query condition with a specified key prefix.
|
Query |
reset() |
Resets this
Query object. |
static Query |
select() |
Obtains an initialized
Query instance. |
Query |
setSuggestIndex(String index) |
Sets a specified index that will be preferentially used for query.
|
Query |
unlike(String field,
String value) |
Constructs a
Query object to query entries with the specified field whose value is not similar
to the specified string value. |
public static Query select()
Query instance.Query instance.public Query reset()
Query object.Query object.public Query equalTo(String field, int value) throws KvStoreException
Query object to query entries with the specified field whose value is equal
to the specified int value.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the int value.Query object.KvStoreException - Throws this exception if input is invalid.public Query equalTo(String field, long value) throws KvStoreException
Query object to query entries with the specified field whose value is equal
to the specified long value.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the long value.Query object.KvStoreException - Throws this exception if input is invalid.public Query equalTo(String field, double value) throws KvStoreException
Query object to query entries with the specified field whose value is equal
to the specified double value.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the double value.Query object.KvStoreException - Throws this exception if input is invalid.public Query equalTo(String field, String value) throws KvStoreException
Query object to query entries with the specified field whose value is equal
to the specified string value.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the string value.Query object.KvStoreException - Throws this exception if input is invalid.public Query equalTo(String field, boolean value) throws KvStoreException
Query object to query entries with the specified field whose value is equal
to the specified boolean value.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the boolean value.Query object.KvStoreException - Throws this exception if input is invalid.public Query notEqualTo(String field, int value) throws KvStoreException
Query object to query entries with the specified field whose value is
not equal to the specified int value.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the int value.Query object.KvStoreException - Throws this exception if input is invalid.public Query notEqualTo(String field, long value) throws KvStoreException
Query object to query entries with the specified field whose value
is not equal to the specified long value.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the long value.Query object.KvStoreException - Throws this exception if input is invalid.public Query notEqualTo(String field, double value) throws KvStoreException
Query object to query entries with the specified field whose value
is not equal to the specified double value.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the double value.Query object.KvStoreException - Throws this exception if input is invalid.public Query notEqualTo(String field, boolean value) throws KvStoreException
Query object to query entries with the specified field whose value is
not equal to the specified boolean value.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the boolean value.Query object.KvStoreException - Throws this exception if input is invalid.public Query notEqualTo(String field, String value) throws KvStoreException
Query object to query entries with the specified field whose value is
not equal to the specified string value.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the string value.Query object.KvStoreException - Throws this exception if input is invalid.public Query greaterThan(String field, int value) throws KvStoreException
Query object to query entries with the specified field whose value is
greater than the specified int value.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the int value.Query object.KvStoreException - Throws this exception if input is invalid.public Query greaterThan(String field, long value) throws KvStoreException
Query object to query entries with the specified field whose value is
greater than the specified long value.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the long value.Query object.KvStoreException - Throws this exception if input is invalid.public Query greaterThan(String field, double value) throws KvStoreException
Query object to query entries with the specified field whose value is
greater than the specified double value.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the double value.Query object.KvStoreException - Throws this exception if input is invalid.public Query greaterThan(String field, String value) throws KvStoreException
Query object to query entries with the specified field whose value is
greater than the specified string value.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the string value.Query object.KvStoreException - Throws this exception if input is invalid.public Query lessThan(String field, int value) throws KvStoreException
Query object to query entries with the specified field whose value is
less than the specified int value.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the int value.Query object.KvStoreException - Throws this exception if input is invalid.public Query lessThan(String field, long value) throws KvStoreException
Query object to query entries with the specified field whose value is less
than the specified long value.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the long value.Query object.KvStoreException - Throws this exception if input is invalid.public Query lessThan(String field, double value) throws KvStoreException
Query object to query entries with the specified field whose value is less
than the specified double value.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the double value.Query object.KvStoreException - Throws this exception if input is invalid.public Query lessThan(String field, String value) throws KvStoreException
Query object to query entries with the specified field whose value is less
than the specified string value.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the string value.Query object.KvStoreException - Throws this exception if input is invalid.public Query greaterThanOrEqualTo(String field, int value) throws KvStoreException
Query object to query entries with the specified field whose value is greater
than or equal to the specified int value.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the int value.Query object.KvStoreException - Throws this exception if input is invalid.public Query greaterThanOrEqualTo(String field, long value) throws KvStoreException
Query object to query entries with the specified field whose value is greater
than or equal to the specified long value.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the long value.Query object.KvStoreException - Throws this exception if input is invalid.public Query greaterThanOrEqualTo(String field, double value) throws KvStoreException
Query object to query entries with the specified field whose value is greater
than or equal to the specified double value.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the double value.Query object.KvStoreException - Throws this exception if input is invalid.public Query greaterThanOrEqualTo(String field, String value) throws KvStoreException
Query object to query entries with the specified field whose value is greater
than or equal to the specified string value. Two strings are compared character by character
lexicographically based on dictionary ordering.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the string value, which cannot contain ^.Query object.KvStoreException - Throws this exception if input is invalid.public Query lessThanOrEqualTo(String field, int value) throws KvStoreException
Query object to query entries with the specified field whose value is less
than or equal to the specified int value.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the int value.Query object.KvStoreException - Throws this exception if input is invalid.public Query lessThanOrEqualTo(String field, long value) throws KvStoreException
Query object to query entries with the specified field whose value is less
than or equal to the specified long value.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the long value.Query object.KvStoreException - Throws this exception if input is invalid.public Query lessThanOrEqualTo(String field, double value) throws KvStoreException
Query object to query entries with the specified field whose value is less
than or equal to the specified double value.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the double value.Query object.KvStoreException - Throws this exception if input is invalid.public Query lessThanOrEqualTo(String field, String value) throws KvStoreException
Query object to query entries with the specified field whose value is less than or
equal to the specified string value. Two strings are compared character by character lexicographically
based on dictionary ordering.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the string value, which cannot contain ^.Query object.KvStoreException - Throws this exception if input is invalid.public Query isNull(String field) throws KvStoreException
Query object to query entries with the specified field whose value is null.field - Indicates the field, which must start with $. and cannot contain ^.Query object.KvStoreException - Throws this exception if input is invalid.public Query inInt(String field, List<Integer> valueList) throws KvStoreException
Query object to query entries with the specified field whose value is within
the specified int value list.field - Indicates the field, which must start with $. and cannot contain ^.valueList - Indicates the int value list.Query object.KvStoreException - Throws this exception if input is invalid.public Query inLong(String field, List<Long> valueList) throws KvStoreException
Query object to query entries with the specified field whose value is within
the specified long value list.field - Indicates the field, which must start with $. and cannot contain ^.valueList - Indicates the long value list.Query object.KvStoreException - Throws this exception if input is invalid.public Query inDouble(String field, List<Double> valueList) throws KvStoreException
Query object to query entries with the specified field whose value is within
the specified double value list.field - Indicates the field, which must start with $. and cannot contain ^.valueList - Indicates the double value list.Query object.KvStoreException - Throws this exception if input is invalid.public Query inString(String field, List<String> valueList) throws KvStoreException
Query object to query entries with the specified field whose value is within
the specified string value list.field - Indicates the field, which must start with $. and cannot contain ^.valueList - Indicates the string value list.Query object.KvStoreException - Throws this exception if input is invalid.public Query notInInt(String field, List<Integer> valueList) throws KvStoreException
Query object to query entries with the specified field whose value is not within
the specified int value list.field - Indicates the field, which must start with $. and cannot contain ^.valueList - Indicates the int value list.Query object.KvStoreException - Throws this exception if input is invalid.public Query notInLong(String field, List<Long> valueList) throws KvStoreException
Query object to query entries with the specified field whose value is not within
the specified long value list.field - Indicates the field, which must start with $. and cannot contain ^.valueList - Indicates the long value list.Query object.KvStoreException - Throws this exception if input is invalid.public Query notInDouble(String field, List<Double> valueList) throws KvStoreException
Query object to query entries with the specified field whose value is not within
the specified double value list.field - Indicates the field, which must start with $. and cannot contain ^.valueList - Indicates the double value list.Query object.KvStoreException - Throws this exception if input is invalid.public Query notInString(String field, List<String> valueList) throws KvStoreException
Query object to query entries with the specified field whose value is not within
the specified string value list.field - Indicates the field, which must start with $. and cannot contain ^.valueList - Indicates the string value list.Query object.KvStoreException - Throws this exception if input is invalid.public Query like(String field, String value) throws KvStoreException
Query object to query entries with the specified field whose value is similar
to the specified string value.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the string value.Query object.KvStoreException - Throws this exception if input is invalid.public Query unlike(String field, String value) throws KvStoreException
Query object to query entries with the specified field whose value is not similar
to the specified string value.field - Indicates the field, which must start with $. and cannot contain ^.value - Indicates the string value.Query object.KvStoreException - Throws this exception if input is invalid.public Query and()
Query object with the and condition.
Multiple predicates should be connected using the and or or condition.
Query object.public Query or()
Query object with the or condition.
Multiple predicates should be connected using the and or or condition.
Query object.public Query orderByAsc(String field) throws KvStoreException
Query object to sort the query results in ascending order.field - Indicates the field, which must start with $. and cannot contain ^.Query object.KvStoreException - Throws this exception if input is invalid.public Query orderByDesc(String field) throws KvStoreException
Query object to sort the query results in descending order.field - Indicates the field, which must start with $. and cannot contain ^.Query object.KvStoreException - Throws this exception if input is invalid.public Query limit(int number, int offset)
Query object to specify the number of results and the start position.number - Indicates the number of results.offset - Indicates the start position.Query object.public Query isNotNull(String field) throws KvStoreException
field - Indicates the specified field.Query object.KvStoreException - Throws this exception if field is incorrect.public Query beginGroup()
Multiple query conditions in an Query object can be grouped.
The query conditions in a group can be used as a whole to combine with other query conditions.
Query object.public Query endGroup()
Multiple query conditions in an Query object can be grouped.
The query conditions in a group can be used as a whole to combine with other query conditions.
Query object.public Query prefixKey(String prefix) throws KvStoreException
prefix - Indicates the specified key prefix.Query object.KvStoreException - Throws this exception if prefix is incorrect.public Query setSuggestIndex(String index)
index - Indicates the index to set.Query object.IllegalArgumentException - Throws this exception if index is incorrect.