Class RealmQuery
On this page
- io.realm
- Method Summary
- Inherited Methods
- Method Detail
- alwaysFalse
- alwaysTrue
- and
- average
- averageDecimal128
- averageRealmAny
- beginGroup
- beginsWith
- between
- contains
- containsEntry
- containsKey
- containsValue
- count
- distinct
- endGroup
- endsWith
- equalTo
- findAll
- findAllAsync
- findFirst
- findFirstAsync
- getDescription
- getQueryPointer
- getRealm
- getTypeQueried
- greaterThan
- greaterThanOrEqualTo
- in
- isEmpty
- isNotEmpty
- isNotNull
- isNull
- isValid
- lessThan
- lessThanOrEqualTo
- like
- limit
- max
- maxRealmAny
- maximumDate
- min
- minRealmAny
- minimumDate
- not
- notEqualTo
- or
- rawPredicate
- sort
- sum
io.realm
A RealmQuery encapsulates a query on a io.realm.Realm or a io.realm.RealmResults using the Builder pattern. The query is executed using either findAll() or findFirst() .
The input to many of the query functions take a field name as String. Note that this is not type safe. If a RealmObject class is refactored care has to be taken to not break any queries.
A io.realm.Realm is unordered, which means that there is no guarantee that querying a Realm will return the objects in the order they where inserted. Use sort(String) (String)} and similar methods if a specific order is required.
A RealmQuery cannot be passed between different threads.
Results are obtained quickly most of the times. However, launching heavy queries from the UI thread may result in a drop of frames or even ANRs. If you want to prevent these behaviors, you can instantiate a Realm using a RealmConfiguration that explicitly sets RealmConfiguration.Builder.allowQueriesOnUiThread(boolean) to false
. This way queries will be forced to be launched from a non-UI thread. Alternatively, you can also use findAllAsync() or findFirstAsync() .
Method Summary
Modifier and Type | Method and Description |
---|---|
public RealmQuery | alwaysFalse () This predicate will never match, resulting in the query always returning 0 results. |
public RealmQuery | alwaysTrue () This predicate will always match. |
public RealmQuery | and () Logical-and two conditions Realm automatically applies logical-and between all query statements, so this is intended only as a mean to increase readability. |
public double | |
public Decimal128 | Returns the average of a given field. |
public Decimal128 | Returns the average of a given field. |
public RealmQuery | beginGroup () Begin grouping of conditions ("left parenthesis"). |
public RealmQuery | Condition that the value of field begins with the specified substring. |
public RealmQuery | Condition that the value of field begins with the specified substring. |
public RealmQuery | Condition that the value of field begins with the specified string. |
public RealmQuery | Condition that the value of field begins with the specified string. |
public RealmQuery | |
public RealmQuery | |
public RealmQuery | |
public RealmQuery | |
public RealmQuery | |
public RealmQuery | |
public RealmQuery | |
public RealmQuery | |
public RealmQuery | |
public RealmQuery | |
public RealmQuery | |
public RealmQuery | Condition that value, if a dictionary field, contains the specified entry. |
public RealmQuery | Condition that value, if a dictionary field, contains the specified key. |
public RealmQuery | Condition that value, if a dictionary field, contains the specified value. |
public RealmQuery | Condition that value, if a dictionary field, contains the specified value. |
public RealmQuery | Condition that value, if a dictionary field, contains the specified value. |
public RealmQuery | Condition that value, if a dictionary field, contains the specified value. |
public RealmQuery | Condition that value, if a dictionary field, contains the specified value. |
public RealmQuery | Condition that value, if a dictionary field, contains the specified value. |
public RealmQuery | Condition that value, if a dictionary field, contains the specified value. |
public RealmQuery | Condition that value, if a dictionary field, contains the specified value. |
public RealmQuery | Condition that value, if a dictionary field, contains the specified value. |
public RealmQuery | Condition that value, if a dictionary field, contains the specified value. |
public RealmQuery | Condition that value, if a dictionary field, contains the specified value. |
public RealmQuery | Condition that value, if a dictionary field, contains the specified value. |
public long | count () Counts the number of objects that fulfill the query conditions. |
public RealmQuery | Selects a distinct set of objects of a specific class. |
public RealmQuery | endGroup () End grouping of conditions ("right parenthesis") which was opened by a call to |
public RealmQuery | |
public RealmQuery | |
public RealmQuery | |
public RealmQuery | |
public RealmQuery | |
public RealmQuery | |
public RealmQuery | |
public RealmQuery | |
public RealmQuery | |
public RealmResults | findAll () Finds all objects that fulfill the query conditions. |
public RealmResults | findAllAsync () Finds all objects that fulfill the query conditions. |
public E | findFirst () Finds the first object that fulfills the query conditions. |
public E | Similar to findFirst() but runs asynchronously on a worker thread. |
public String | Returns a textual description of this query. |
public long | Returns the pointer to the underlying C++ query. |
public Realm | |
public String | Returns the internal Realm name of the type being queried. |
public RealmQuery | Greater-than comparison. |
public RealmQuery | Greater-than comparison. |
public RealmQuery | Greater-than comparison. |
public RealmQuery | Greater-than comparison. |
public RealmQuery | Greater-than comparison. |
public RealmQuery | Greater-than comparison. |
public RealmQuery | Greater-than comparison. |
public RealmQuery | Greater-than comparison. |
public RealmQuery | Greater-than-or-equal-to comparison. |
public RealmQuery | Greater-than-or-equal-to comparison. |
public RealmQuery | Greater-than-or-equal-to comparison. |
public RealmQuery | Greater-than-or-equal-to comparison. |
public RealmQuery | Greater-than-or-equal-to comparison. |
public RealmQuery | Greater-than-or-equal-to comparison. |
public RealmQuery | Greater-than-or-equal-to comparison. |
public RealmQuery | In comparison. |
public RealmQuery | In comparison. |
public RealmQuery | In comparison. |
public RealmQuery | In comparison. |
public RealmQuery | In comparison. |
public RealmQuery | In comparison. |
public RealmQuery | In comparison. |
public RealmQuery | In comparison. |
public RealmQuery | In comparison. |
public RealmQuery | In comparison. |
public RealmQuery | In comparison. |
public RealmQuery | |
public RealmQuery | Condition that finds values that are considered "Not-empty" i.e., a list, a string or a byte array with not-empty values. |
public RealmQuery | |
public RealmQuery | |
public boolean | isValid () Checks if io.realm.RealmQuery is still valid to use i.e., the io.realm.Realm instance hasn't been closed and any parent io.realm.RealmResults is still valid. |
public RealmQuery | |
public RealmQuery | |
public RealmQuery | |
public RealmQuery | |
public RealmQuery | Less-than-or-equal-to comparison. |
public RealmQuery | Less-than-or-equal-to comparison. |
public RealmQuery | Less-than-or-equal-to comparison. |
public RealmQuery | Less-than-or-equal-to comparison. |
public RealmQuery | |
public RealmQuery | |
public RealmQuery | |
public RealmQuery | |
public RealmQuery | Limits the number of objects returned in case the query matched more objects. |
public Number | |
public RealmAny | Finds the maximum value of a RealmAny field. |
public Date | Finds the maximum value of a field. |
public Number | |
public RealmAny | Finds the minimum value of a RealmAny field. |
public Date | Finds the minimum value of a field. |
public RealmQuery | not () Negate condition. |
public RealmQuery | Not-equal-to comparison. |
public RealmQuery | Not-equal-to comparison. |
public RealmQuery | Not-equal-to comparison. |
public RealmQuery | Not-equal-to comparison. |
public RealmQuery | Not-equal-to comparison. |
public RealmQuery | or () Logical-or two conditions. |
public RealmQuery | Create a text-based predicate using the Realm Query Language. |
public RealmQuery | Sorts the query result by the specific field names in the provided orders. |
public RealmQuery | |
public RealmQuery | |
public RealmQuery | |
public Number |
Inherited Methods
Methods inherited from class java.lang.Object :
getClass
,hashCode
,equals
,clone
,toString
,notify
,notifyAll
,wait
,wait
,wait
,finalize
Method Detail
alwaysFalse
public RealmQuery alwaysFalse () |
---|
This predicate will never match, resulting in the query always returning 0 results. |
alwaysTrue
public RealmQuery alwaysTrue () |
---|
This predicate will always match. |
and
public RealmQuery and () |
---|
Logical-and two conditions Realm automatically applies logical-and between all query statements, so this is intended only as a mean to increase readability. Returns the query object |
average
Returns the average of a given field. Does not support dotted field notation. Parameters
Returns the average for the given field amongst objects in query results. This will be of type double for all types of number fields. If no objects exist or they all have Throws
|
averageDecimal128
Returns the average of a given field. Does not support dotted field notation. Parameters
Returns the average for the given field amongst objects in query results. This will be of type Decimal128. If no objects exist or they all have Throws
|
averageRealmAny
Returns the average of a given field. Does not support dotted field notation. Parameters
Returns the average for the given field amongst objects in query results. This will be of type Decimal128. If no objects exist or they all have Throws
|
beginGroup
public RealmQuery beginGroup () |
---|
Begin grouping of conditions ("left parenthesis"). A group must be closed with a call to Returns the query object. |
beginsWith
Condition that the value of field begins with the specified substring. Parameters
Returns the query object Throws
|
Condition that the value of field begins with the specified substring. Parameters
Returns the query object Throws
|
Condition that the value of field begins with the specified string. Parameters
Returns the query object. Throws
|
Condition that the value of field begins with the specified string. Parameters
Returns the query object. Throws
|
between
Between condition. Parameters
Returns the query object. Throws
|
Between condition. Parameters
Returns the query object. Throws
|
Between condition. Parameters
Returns the query object. Throws
|
Between condition. Parameters
Returns the query object. Throws
|
Between condition. Parameters
Returns the query object. Throws
|
Between condition. Parameters
Returns the query object. Throws
|
Between condition. Parameters
Returns the query object. Throws
|
contains
Condition that value of field contains the specified substring. Parameters
Returns The query object. Throws
|
Condition that value of field contains the specified substring. Parameters
Returns The query object. Throws
|
Condition that value of field contains the specified substring. Parameters
Returns the query object. Throws
|
Condition that value of field contains the specified substring. Parameters
Returns the query object. Throws
|
containsEntry
Condition that value, if a dictionary field, contains the specified entry. Parameters
Returns the query object. Throws
|
containsKey
Condition that value, if a dictionary field, contains the specified key. Parameters
Returns the query object. Throws
|
containsValue
Condition that value, if a dictionary field, contains the specified value. Parameters
Returns the query object. Throws
|
Condition that value, if a dictionary field, contains the specified value. Parameters
Returns the query object. Throws
|
Condition that value, if a dictionary field, contains the specified value. Parameters
Returns the query object. Throws
|
Condition that value, if a dictionary field, contains the specified value. Parameters
Returns the query object. Throws
|
Condition that value, if a dictionary field, contains the specified value. Parameters
Returns the query object. Throws
|
Condition that value, if a dictionary field, contains the specified value. Parameters
Returns the query object. Throws
|
Condition that value, if a dictionary field, contains the specified value. Parameters
Returns the query object. Throws
|
Condition that value, if a dictionary field, contains the specified value. Parameters
Returns the query object. Throws
|
Condition that value, if a dictionary field, contains the specified value. Parameters
Returns the query object. Throws
|
Condition that value, if a dictionary field, contains the specified value. Parameters
Returns the query object. Throws
|
Condition that value, if a dictionary field, contains the specified value. Parameters
Returns the query object. Throws
|
Condition that value, if a dictionary field, contains the specified value. Parameters
Returns the query object. Throws
|
count
public long count () |
---|
Counts the number of objects that fulfill the query conditions. Returns the number of matching objects. Throws
|
distinct
Selects a distinct set of objects of a specific class. When multiple distinct fields are given, all unique combinations of values in the fields will be returned. In case of multiple matches, it is undefined which object is returned. Unless the result is sorted, then the first object will be returned. Parameters
Throws
|
endGroup
public RealmQuery endGroup () |
---|
End grouping of conditions ("right parenthesis") which was opened by a call to Returns the query object. |
endsWith
Condition that the value of field ends with the specified substring. Parameters
Returns the query object. Throws
|
Condition that the value of field ends with the specified substring. Parameters
Returns the query object. Throws
|
Condition that the value of field ends with the specified string. Parameters
Returns the query object. Throws
|
Condition that the value of field ends with the specified string. Parameters
Returns the query object. Throws
|
equalTo
Equal-to comparison. Parameters
Returns the query object. Throws
|
Equal-to comparison. Parameters
Returns the query object. Throws
|
Equal-to comparison. Parameters
Returns the query object. Throws
|
Equal-to comparison. Parameters
Returns the query object. Throws
|
Equal-to comparison. Parameters
Returns the query object. Throws
|
findAll
public RealmResults findAll () |
---|
Finds all objects that fulfill the query conditions.Launching heavy queries from the UI thread may result in a drop of frames or even ANRs. We do not recommend doing so and therefore it is not allowed by default. If you want to prevent these behaviors you can obtain a Realm using a RealmConfiguration that explicitly sets RealmConfiguration.Builder.allowQueriesOnUiThread(boolean) to Returns a io.realm.RealmResults containing objects. If no objects match the condition, a list with zero objects is returned. Throws
|