RealmQuery
A RealmQuery
encapsulates a query on a Realm, a RealmResults or a RealmList instance using the Builder
pattern. The query is executed using either find or subscribing to the Flow returned by asFlow.
A Realm is unordered, which means that there is no guarantee that a query will return the objects in the order they where inserted. Use the sort functions if a specific order is required.
Results are obtained quickly most of the times when using find. 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 use asFlow and collect the results asynchronously.
Parameters
the class of the objects to be queried.
Functions
Returns a RealmScalarQuery that counts the number of objects that fulfill the query conditions.
Returns a textual description of the query.
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.
Finds all objects that fulfill the query conditions and returns them in a blocking fashion.
Similar to RealmQuery.find but it receives a block in which the RealmResults from the query are provided.
Returns a query that finds the first object that fulfills the query conditions.
Limits the number of objects returned in case the query matched more objects.
Similar to RealmQuery.max but the type parameter is automatically inferred.
Similar to RealmQuery.min but the type parameter is automatically inferred.
Sorts the query result by the specific property name according to Pairs of properties and sorting order.
Sorts the query result by the specific property name according to sortOrder, which is Sort.ASCENDING by default.
Similar to RealmQuery.sum but the type parameter is automatically inferred.