Join us at MongoDB.local London on 7 May to unlock new possibilities for your data. Use WEB50 to save 50%.
Register now >
Docs Menu
Docs Home
/ /
io.realm

Class RealmQuery

java.lang.Object
io.realm.RealmQuery

Una RealmQuery encapsula una query en un io.realm.realm o un io.realm.RealmResults utilizando el patrón Builder. La consulta se ejecuta usando findAll() o 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.

Un io.realm.Realm no está ordenado, lo que significa que no hay garantía de que al consultar un Realm se devuelvan los objetos en el orden en que se insertaron. Utilice sort(String) (String)} y métodos similares si se requiere un orden específico.

Una RealmQuery no se puede pasar entre diferentes hilos.

La mayoría de las veces, los resultados se obtienen rápidamente. Sin embargo, ejecutar consultas pesadas desde el hilo de la interfaz de usuario puede provocar una pérdida de fotogramas o incluso ANR. Para evitar estos comportamientos, puede instanciar un dominio usando una RealmConfiguration que establezca explícitamente RealmConfiguration.Builder.allowQueriesOnUiThread(boolean) en false De esta forma, las consultas se verán obligadas a iniciarse desde un hilo que no sea de interfaz de usuario. Como alternativa, también puede usar findAllAsync() o findFirstAsync().

Tip

Modificador y Tipo
Método y descripción

Este predicado nunca coincidirá, resultando en que la query siempre devuelva 0 resultados.

This predicate will always match.

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

String fieldName
)

Devuelve el promedio de un campo dado.

público Decimal128

Devuelve el promedio de un campo dado.

público Decimal128

Devuelve el promedio de un campo dado.

Begin grouping of conditions ("left parenthesis").

String fieldName,
RealmAny value,
Case casing
)

Condition that the value of field begins with the specified substring.

String fieldName,
String value,
Case casing
)

Condition that the value of field begins with the specified substring.

String fieldName,
RealmAny value
)

Condición de que el valor del campo comience con la cadena especificada.

String fieldName,
String value
)

Condición de que el valor del campo comience con la cadena especificada.

String fieldName,
Decimal128 from,
Decimal128 to
)

Between condition.

String fieldName,
RealmAny from,
)

Between condition.

String fieldName,
Date from,
Date to
)

Between condition.

String fieldName,
float from,
float to
)

Between condition.

String fieldName,
double from,
double to
)

Between condition.

String fieldName,
long from,
long to
)

Between condition.

String fieldName,
int from,
int to
)

Between condition.

String fieldName,
RealmAny value,
Case casing
)

Condición de que el valor del campo contenga la subcadena especificada.

String fieldName,
String value,
Case casing
)

Condición de que el valor del campo contenga la subcadena especificada.

String fieldName,
RealmAny value
)

Condición de que el valor del campo contenga la subcadena especificada.

String fieldName,
String value
)

Condición de que el valor del campo contenga la subcadena especificada.

Condición de que el valor, si es un campo de diccionario, contenga la entrada especificada.

String fieldName,
String key
)

Condition that value, if a dictionary field, contains the specified key.

String fieldName,
ObjectId value
)

Condición de que el valor, si es un campo de diccionario, contenga el valor especificado.

String fieldName,
Decimal128 value
)

Condición de que el valor, si es un campo de diccionario, contenga el valor especificado.

String fieldName,
Date value
)

Condición de que el valor, si es un campo de diccionario, contenga el valor especificado.

String fieldName,
byte[] value
)

Condición de que el valor, si es un campo de diccionario, contenga el valor especificado.

String fieldName,
String value
)

Condición de que el valor, si es un campo de diccionario, contenga el valor especificado.

String fieldName,
Float value
)

Condición de que el valor, si es un campo de diccionario, contenga el valor especificado.

String fieldName,
Double value
)

Condición de que el valor, si es un campo de diccionario, contenga el valor especificado.

String fieldName,
Long value
)

Condición de que el valor, si es un campo de diccionario, contenga el valor especificado.

String fieldName,
Integer value
)

Condición de que el valor, si es un campo de diccionario, contenga el valor especificado.

String fieldName,
Short value
)

Condición de que el valor, si es un campo de diccionario, contenga el valor especificado.

String fieldName,
Byte value
)

Condición de que el valor, si es un campo de diccionario, contenga el valor especificado.

String fieldName,
Boolean value
)

Condición de que el valor, si es un campo de diccionario, contenga el valor especificado.

public long

Cuenta el número de objetos que cumplen las condiciones de consulta.

String firstFieldName,
java.lang.String[] remainingFieldNames
)

Selects a distinct set of objects of a specific class.

End grouping of conditions ("right parenthesis") which was opened by a call to beginGroup() .

String fieldName,
RealmAny value,
Case casing
)

Condition that the value of field ends with the specified substring.

String fieldName,
String value,
Case casing
)

Condition that the value of field ends with the specified substring.

String fieldName,
RealmAny value
)

Condition that the value of field ends with the specified string.

String fieldName,
String value
)

Condition that the value of field ends with the specified string.

String fieldName,
ObjectId value
)

Equal-to comparison.

String fieldName,
Decimal128 value
)

Equal-to comparison.

String fieldName,
RealmAny value,
Case casing
)

Equal-to comparison.

String fieldName,
String value,
Case casing
)

Equal-to comparison.

String fieldName,
String value
)

Equal-to comparison.

Encuentra todos los objetos que cumplen las condiciones de la query.

Encuentra todos los objetos que cumplen las condiciones de la query.

public E

Encuentra el primer objeto que cumple las condiciones de la consulta.

public E

Similar a findFirst() pero se ejecuta de forma asíncrona en un hilo de trabajo.

public String

Retorna una descripción textual de esta query.

public long

Devuelve el puntero a la consulta C++ subyacente.

public Realm

Returns the Realm instance to which this query belongs.

public String

Devuelve el nombre del reino interno del tipo que se está consultando.

String fieldName,
ObjectId value
)

Greater-than comparison.

String fieldName,
Decimal128 value
)

Greater-than comparison.

String fieldName,
RealmAny value
)

Greater-than comparison.

String fieldName,
Date value
)

Greater-than comparison.

String fieldName,
float value
)

Greater-than comparison.

String fieldName,
double value
)

Greater-than comparison.

String fieldName,
long value
)

Greater-than comparison.

String fieldName,
int value
)

Greater-than comparison.

String fieldName,
ObjectId value
)

Greater-than-or-equal-to comparison.

String fieldName,
Decimal128 value
)

Greater-than-or-equal-to comparison.

String fieldName,
Date value
)

Greater-than-or-equal-to comparison.

String fieldName,
float value
)

Greater-than-or-equal-to comparison.

String fieldName,
double value
)

Greater-than-or-equal-to comparison.

String fieldName,
long value
)

Greater-than-or-equal-to comparison.

String fieldName,
int value
)

Greater-than-or-equal-to comparison.

in (
String fieldName,
)

In comparison.

in (
String fieldName,
)

In comparison.

in (
String fieldName,
)

In comparison.

in (
String fieldName,
)

In comparison.

in (
String fieldName,
)

In comparison.

in (
String fieldName,
)

In comparison.

in (
String fieldName,
)

In comparison.

in (
String fieldName,
)

In comparison.

in (
String fieldName,
)

In comparison.

in (
String fieldName,
Case casing
)

In comparison.

in (
String fieldName,
)

In comparison.

String fieldName
)

Condition that finds values that are considered "empty" i.e., an empty list, the 0-length string or byte array.

String fieldName
)

Condition that finds values that are considered "Not-empty" i.e., a list, a string or a byte array with not-empty values.

String fieldName
)

Tests if a field is not null .

String fieldName
)

Tests if a field is null .

public booleano

Comprueba si io.realm.RealmQuery sigue siendo válido para su uso, es decir, que la instancia Realm no ha sido cerrada y cualquier io.realm.RealmResults principal sigue siendo válido.

String fieldName,
ObjectId value
)

Less-than comparison.

String fieldName,
Decimal128 value
)

Less-than comparison.

String fieldName,
long value
)

Less-than comparison.

String fieldName,
int value
)

Less-than comparison.

String fieldName,
ObjectId value
)

Comparación menor o igual a.

String fieldName,
Decimal128 value
)

Comparación menor o igual a.

String fieldName,
long value
)

Comparación menor o igual a.

String fieldName,
int value
)

Comparación menor o igual a.

String fieldName,
RealmAny value,
Case casing
)

Condición de que el valor de un campo coincida con la subcadena especificada, con comodines:

  • '*' coincide con [0, n] caracteres unicode

  • '?' matches a single unicode char.

String fieldName,
String value,
Case casing
)

Condición de que el valor de un campo coincida con la subcadena especificada, con comodines:

  • '*' coincide con [0, n] caracteres unicode

  • '?' matches a single unicode char.

String fieldName,
RealmAny value
)

Condición de que el valor de un campo coincida con la subcadena especificada, con comodines:

  • '*' coincide con [0, n] caracteres unicode

  • '?' matches a single unicode char.

String fieldName,
String value
)

Condición de que el valor de un campo coincida con la subcadena especificada, con comodines:

  • '*' coincide con [0, n] caracteres unicode

  • '?' matches a single unicode char.

long limit
)

Limits the number of objects returned in case the query matched more objects.

public Number

max (
String fieldName
)

Finds the maximum value of a field.

público RealmAny

String fieldName
)

Encuentra el valor máximo de un campo RealmAny.

public Date

String fieldName
)

Finds the maximum value of a field.

public Number

min (
String fieldName
)

Finds the minimum value of a field.

público RealmAny

String fieldName
)

Busca el valor mínimo de un campo RealmAny.

public Date

String fieldName
)

Finds the minimum value of a field.

not ()

Negate condition.

String fieldName,
ObjectId value
)

Not-equal-to comparison.

String fieldName,
Decimal128 value
)

Not-equal-to comparison.

String fieldName,
RealmAny value,
Case casing
)

Not-equal-to comparison.

String fieldName,
String value,
Case casing
)

Not-equal-to comparison.

String fieldName,
String value
)

Not-equal-to comparison.

or ()

Logical-or two conditions.

String predicate,
)

Create a text-based predicate using the Realm Query Language.

java.lang.String[] fieldNames,
io.realm.Sort[] sortOrders
)

Sorts the query result by the specific field names in the provided orders.

String fieldName1,
Sort sortOrder1,
String fieldName2,
Sort sortOrder2
)

Sorts the query result by the specific field names in the provided orders.

String fieldName,
Sort sortOrder
)

Sorts the query result by the specified field name and order.

String fieldName
)

Sorts the query result by the specific field name in ascending order.

public Number

sum (
String fieldName
)

Calculates the sum of a given field.

  • Methods inherited from class java.lang.Object : getClass , hashCode , equals , clone , toString , notify , notifyAll , wait , wait , wait , finalize

Este predicado nunca coincidirá, resultando en que la query siempre devuelva 0 resultados.

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.

Devuelve

the query object

public double average (
String fieldName
)

Devuelve el promedio de un campo determinado. No ofrece soporte para la notación de campo con puntos.

Parámetros

  • fieldName - el campo sobre el que calcular el promedio. Sólo se admiten campos numéricos.

Devuelve

el promedio del campo indicado entre los objetos de los resultados de la query. Esto será del tipo double para todos los campos de tipo numérico. Si no existen objetos o todos tienen null como valor para el campo dado, 0 será devuelto. Al calcular el promedio, se ignoran los objetos con valores null.

Throws

public Decimal128 averageDecimal128 (
String fieldName
)

Devuelve el promedio de un campo determinado. No ofrece soporte para la notación de campo con puntos.

Parámetros

  • fieldName - El campo para calcular el promedio. Solo128 se admiten campos decimales. Para otros tipos de números, considere usar average(String).

Devuelve

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 null as the value for the given field 0 will be returned. When computing the average, objects with null values are ignored.

Throws

public Decimal128 averageRealmAny (
String fieldName
)

Devuelve el promedio de un campo determinado. No ofrece soporte para la notación de campo con puntos.

Parámetros

  • fieldName - El campo para calcular el promedio. Solo se admiten campos RealmAny. Para otros tipos, considere usar average(String).

Devuelve

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 null as the value for the given field 0 will be returned. When computing the average, objects with null values are ignored.

Throws

Comienza el agrupamiento de condiciones ("paréntesis izquierdo"). Un grupo debe cerrarse con una llamada a endGroup() .

Devuelve

the query object.

String fieldName,
RealmAny value,
Case casing
)

Condition that the value of field begins with the specified substring.

Parámetros

  • fieldName - the field to compare.

  • value - la subcadena.

  • casing - how to handle casing. Setting this to Case.INSENSITIVE only works for Latin-1 characters.

Devuelve

the query object

Throws

String fieldName,
String value,
Case casing
)

Condition that the value of field begins with the specified substring.

Parámetros

  • fieldName - the field to compare.

  • value - la subcadena.

  • casing - how to handle casing. Setting this to Case.INSENSITIVE only works for Latin-1 characters.

Devuelve

the query object

Throws

String fieldName,
RealmAny value
)

Condición de que el valor del campo comience con la cadena especificada.

Parámetros

  • fieldName - the field to compare.

  • value - la cuerda.

Devuelve

the query object.

Throws

String fieldName,
String value
)

Condición de que el valor del campo comience con la cadena especificada.

Parámetros

  • fieldName - the field to compare.

  • value - la cuerda.

Devuelve

the query object.

Throws

String fieldName,
Decimal128 from,
Decimal128 to
)

Between condition.

Parámetros

  • fieldName - the field to compare.

  • from - lowest value (inclusive).

  • to - highest value (inclusive).

Devuelve

the query object.

Throws

String fieldName,
RealmAny from,
)

Between condition.

Parámetros

  • fieldName - the field to compare.

  • from - lowest value (inclusive).

  • to - highest value (inclusive).

Devuelve

the query object.

Throws

String fieldName,
Date from,
Date to
)

Between condition.

Parámetros

  • fieldName - the field to compare.

  • from - lowest value (inclusive).

  • to - highest value (inclusive).

Devuelve

the query object.

Throws

String fieldName,
float from,
float to
)

Between condition.

Parámetros

  • fieldName - the field to compare.

  • from - lowest value (inclusive).

  • to - highest value (inclusive).

Devuelve

the query object.

Throws

String fieldName,
double from,
double to
)

Between condition.

Parámetros

  • fieldName - the field to compare.

  • from - lowest value (inclusive).

  • to - highest value (inclusive).

Devuelve

the query object.

Throws

String fieldName,
long from,
long to
)

Between condition.

Parámetros

  • fieldName - the field to compare.

  • from - lowest value (inclusive).

  • to - highest value (inclusive).

Devuelve

the query object.

Throws

String fieldName,
int from,
int to
)

Between condition.

Parámetros

  • fieldName - the field to compare.

  • from - lowest value (inclusive).

  • to - highest value (inclusive).

Devuelve

the query object.

Throws

String fieldName,
RealmAny value,
Case casing
)

Condición de que el valor del campo contenga la subcadena especificada.

Parámetros

  • fieldName - the field to compare.

  • value - la subcadena.

  • casing - how to handle casing. Setting this to Case.INSENSITIVE only works for Latin-1 characters.

Devuelve

El objeto de consulta.

Throws

String fieldName,
String value,
Case casing
)

Condición de que el valor del campo contenga la subcadena especificada.

Parámetros

  • fieldName - the field to compare.

  • value - la subcadena.

  • casing - how to handle casing. Setting this to Case.INSENSITIVE only works for Latin-1 characters.

Devuelve

El objeto de consulta.

Throws

String fieldName,
RealmAny value
)

Condición de que el valor del campo contenga la subcadena especificada.

Parámetros

  • fieldName - the field to compare.

  • value - la subcadena.

Devuelve

the query object.

Throws

String fieldName,
String value
)

Condición de que el valor del campo contenga la subcadena especificada.

Parámetros

  • fieldName - the field to compare.

  • value - la subcadena.

Devuelve

the query object.

Throws

Condición de que el valor, si es un campo de diccionario, contenga la entrada especificada.

Parámetros

  • fieldName - the field to compare.

  • entry - the entry to search for.

Devuelve

the query object.

Throws

String fieldName,
String key
)

Condition that value, if a dictionary field, contains the specified key.

Parámetros

  • fieldName - the field to compare.

  • key - the key to search for.

Devuelve

the query object.

Throws

String fieldName,
ObjectId value
)

Condición de que el valor, si es un campo de diccionario, contenga el valor especificado.

Parámetros

  • fieldName - the field to compare.

  • value - the value to search for.

Devuelve

the query object.

Throws

String fieldName,
Decimal128 value
)

Condición de que el valor, si es un campo de diccionario, contenga el valor especificado.

Parámetros

  • fieldName - the field to compare.

  • value - the value to search for.

Devuelve

the query object.

Throws

String fieldName,
Date value
)

Condición de que el valor, si es un campo de diccionario, contenga el valor especificado.

Parámetros

  • fieldName - the field to compare.

  • value - the value to search for.

Devuelve

the query object.

Throws

String fieldName,
byte[] value
)

Condición de que el valor, si es un campo de diccionario, contenga el valor especificado.

Parámetros

  • fieldName - the field to compare.

  • value - the value to search for.

Devuelve

the query object.

Throws

String fieldName,
String value
)

Condición de que el valor, si es un campo de diccionario, contenga el valor especificado.

Parámetros

  • fieldName - the field to compare.

  • value - the value to search for.

Devuelve

the query object.

Throws

String fieldName,
Float value
)

Condición de que el valor, si es un campo de diccionario, contenga el valor especificado.

Parámetros

  • fieldName - the field to compare.

  • value - the value to search for.

Devuelve

the query object.

Throws

String fieldName,
Double value
)

Condición de que el valor, si es un campo de diccionario, contenga el valor especificado.

Parámetros

  • fieldName - the field to compare.

  • value - the value to search for.

Devuelve

the query object.

Throws

String fieldName,
Long value
)

Condición de que el valor, si es un campo de diccionario, contenga el valor especificado.

Parámetros

  • fieldName - the field to compare.

  • value - the value to search for.

Devuelve

the query object.

Throws

String fieldName,
Integer value
)

Condición de que el valor, si es un campo de diccionario, contenga el valor especificado.

Parámetros

  • fieldName - the field to compare.

  • value - the value to search for

Devuelve

the query object.

Throws

String fieldName,
Short value
)

Condición de que el valor, si es un campo de diccionario, contenga el valor especificado.

Parámetros

  • fieldName - the field to compare.

  • value - the value to search for.

Devuelve

the query object.

Throws

String fieldName,
Byte value
)

Condición de que el valor, si es un campo de diccionario, contenga el valor especificado.

Parámetros

  • fieldName - the field to compare.

  • value - the value to search for.

Devuelve

the query object.

Throws

String fieldName,
Boolean value
)

Condición de que el valor, si es un campo de diccionario, contenga el valor especificado.

Parámetros

  • fieldName - the field to compare.

  • value - the value to search for.

Devuelve

the query object.

Throws

public long count ()

Cuenta el número de objetos que cumplen las condiciones de consulta.

Devuelve

el número de objetos coincidentes.

Throws

String firstFieldName,
java.lang.String[] remainingFieldNames
)

Selecciona un conjunto distinto de objetos de una clase específica. Cuando se proporcionan varios campos distintos, se devolverán todas las combinaciones únicas de valores en los campos. En caso de múltiples coincidencias, no está definido qué objeto se retorna. A menos que el resultado esté ordenado, entonces se retornará el primer objeto.

Parámetros

  • firstFieldName - first field name to use when finding distinct objects.

  • remainingFieldNames - nombres de los campos restantes al determinar todas las combinaciones únicas de valores de campo.

Throws

End grouping of conditions ("right parenthesis") which was opened by a call to beginGroup() .

Devuelve

the query object.

String fieldName,
RealmAny value,
Case casing
)

Condition that the value of field ends with the specified substring.

Parámetros

  • fieldName - the field to compare.

  • value - la subcadena.

  • casing - how to handle casing. Setting this to Case.INSENSITIVE only works for Latin-1 characters.

Devuelve

the query object.

Throws

String fieldName,
String value,
Case casing
)

Condition that the value of field ends with the specified substring.

Parámetros

  • fieldName - the field to compare.

  • value - la subcadena.

  • casing - how to handle casing. Setting this to Case.INSENSITIVE only works for Latin-1 characters.

Devuelve

the query object.

Throws

String fieldName,
RealmAny value
)

Condition that the value of field ends with the specified string.

Parámetros

  • fieldName - the field to compare.

  • value - la cuerda.

Devuelve

the query object.

Throws

String fieldName,
String value
)

Condition that the value of field ends with the specified string.

Parámetros

  • fieldName - the field to compare.

  • value - la cuerda.

Devuelve

the query object.

Throws

String fieldName,
ObjectId value
)

Equal-to comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

String fieldName,
Decimal128 value
)

Equal-to comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

String fieldName,
RealmAny value,
Case casing
)

Equal-to comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

  • casing - how to handle casing. Setting this to Case.INSENSITIVE only works for Latin-1 characters.

Devuelve

the query object.

Throws

String fieldName,
String value,
Case casing
)

Equal-to comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

  • casing - how to handle casing. Setting this to Case.INSENSITIVE only works for Latin-1 characters.

Devuelve

the query object.

Throws

String fieldName,
String value
)

Equal-to comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

Encuentra todos los objetos que cumplen las condiciones de la query.Lanzar queries pesadas desde el hilo de la Interfaz de Usuario puede resultar en una caída de cuadros o incluso en ANRs. No recomendamos hacerlo y por lo tanto no está permitido por defecto. Si deseas evitar estos comportamientos puedes obtener un Realm utilizando una RealmConfiguration que establezca explícitamente RealmConfiguration.Builder.allowQueriesOnUiThread(boolean) a false . De esta manera, te verás obligado a ejecutar tus consultas desde un hilo que no sea de la Interfaz de Usuario. De lo contrario, las llamadas a este método provocarán un RealmException . Alternativamente, puedes usar findAllAsync() .

Devuelve

a io.realm.RealmResults containing objects. If no objects match the condition, a list with zero objects is returned.

Throws

Encuentra todos los objetos que cumplen con las condiciones de la query. Este método solo está disponible desde un hilo Looper.

Devuelve

immediately an empty RealmResults . Users need to register a listener io.realm.RealmResults.addChangeListener(RealmChangeListener) to be notified when the query completes.

public E findFirst ()

Encuentra el primer objeto que cumple con las condiciones de la query.Lanzar consultas pesadas desde el hilo de la UI puede resultar en una caída de fotogramas o incluso en ANRs. No recomendamos hacer esto, pero está permitido por defecto. Si desea evitar estos comportamientos, puede obtener un Realm utilizando una RealmConfiguration que establezca explícitamente RealmConfiguration.Builder.allowQueriesOnUiThread(booleano) a false . De esta manera te verás obligado a lanzar tus queries desde un hilo de Interfaz de Usuario, de lo contrario las llamadas a este método lanzarán un RealmException . Como alternativa, puedes usar findFirstAsync() .

Devuelve

el objeto encontrado o null si ningún objeto coincide con las condiciones de la query.

Throws

public E findFirstAsync ()

Similar a findFirst() pero se ejecuta de forma asíncrona en un hilo de trabajo. Se debe registrar un listener en el RealmObject devuelto para recibir la notificación cuando la query finalice. El listener registrado también se activará si se realizan cambios en el RealmObject query. Si el RealmObject se borra, el listener será llamado una última vez y luego se detendrá. La query no se volverá a ejecutar.

Devuelve

immediately an empty RealmObject with isLoaded() == false . Trying to access any field on the returned object before it is loaded will throw an IllegalStateException .

Throws

Retorna una descripción textual de esta query.

Devuelve

la descripción textual de la consulta.

public long getQueryPointer ()

Retorna el puntero a la query subyacente en C++. Este método es público solo debido a decisiones de diseño arquitectónico que son difíciles de resolver y debe considerarse interno y puede cambiar sin previo aviso.

Devuelve

the pointer to the underlying C++ query.

public Realm getRealm ()

Returns the Realm instance to which this query belongs.

Calling Realm.close() on the returned instance is discouraged as it is the same as calling it on the original Realm instance which may cause the Realm to fully close invalidating the query.

Devuelve

Realm instance this query belongs to.

Throws

Devuelve el nombre del reino interno del tipo que se está consultando.

Devuelve

el nombre interno de la clase del modelo Realm que se está consultando.

String fieldName,
ObjectId value
)

Greater-than comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

String fieldName,
Decimal128 value
)

Greater-than comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

String fieldName,
RealmAny value
)

Greater-than comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

String fieldName,
Date value
)

Greater-than comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

String fieldName,
float value
)

Greater-than comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

String fieldName,
double value
)

Greater-than comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

String fieldName,
long value
)

Greater-than comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

String fieldName,
int value
)

Greater-than comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

String fieldName,
ObjectId value
)

Greater-than-or-equal-to comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

String fieldName,
Decimal128 value
)

Greater-than-or-equal-to comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

String fieldName,
Date value
)

Greater-than-or-equal-to comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

String fieldName,
float value
)

Greater-than-or-equal-to comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

String fieldName,
double value
)

Greater-than-or-equal-to comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

String fieldName,
long value
)

Greater-than-or-equal-to comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

String fieldName,
int value
)

Greater-than-or-equal-to comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

public RealmQuery in (
String fieldName,
)

In comparison. This allows you to test if objects match any value in an array of values.

Parámetros

  • fieldName - the field to compare.

  • values - array of values to compare with. If null or the empty array is provided the query will never match any results.

Devuelve

the query object.

Throws

public RealmQuery in (
String fieldName,
)

In comparison. This allows you to test if objects match any value in an array of values.

Parámetros

  • fieldName - the field to compare.

  • values - array of values to compare with. If null or the empty array is provided the query will never match any results.

Devuelve

the query object.

Throws

public RealmQuery in (
String fieldName,
)

In comparison. This allows you to test if objects match any value in an array of values.

Parámetros

  • fieldName - the field to compare.

  • values - array of values to compare with. If null or the empty array is provided the query will never match any results.

Devuelve

the query object.

Throws

public RealmQuery in (
String fieldName,
)

In comparison. This allows you to test if objects match any value in an array of values.

Parámetros

  • fieldName - the field to compare.

  • values - array of values to compare with. If null or the empty array is provided the query will never match any results.

Devuelve

the query object.

Throws

public RealmQuery in (
String fieldName,
)

In comparison. This allows you to test if objects match any value in an array of values.

Parámetros

  • fieldName - the field to compare.

  • values - array of values to compare with. If null or the empty array is provided the query will never match any results.

Devuelve

the query object.

Throws

public RealmQuery in (
String fieldName,
)

In comparison. This allows you to test if objects match any value in an array of values.

Parámetros

  • fieldName - the field to compare.

  • values - array of values to compare with. If null or the empty array is provided the query will never match any results.

Devuelve

the query object.

Throws

public RealmQuery in (
String fieldName,
)

In comparison. This allows you to test if objects match any value in an array of values.

Parámetros

  • fieldName - the field to compare.

  • values - array of values to compare with. If null or the empty array is provided the query will never match any results.

Devuelve

the query object.

Throws

public RealmQuery in (
String fieldName,
)

In comparison. This allows you to test if objects match any value in an array of values.

Parámetros

  • fieldName - the field to compare.

  • values - array of values to compare with. If null or the empty array is provided the query will never match any results.

Devuelve

the query object.

Throws

public RealmQuery in (
String fieldName,
)

In comparison. This allows you to test if objects match any value in an array of values.

Parámetros

  • fieldName - the field to compare.

  • values - array of values to compare with. If null or the empty array is provided the query will never match any results.

Devuelve

the query object.

Throws

public RealmQuery in (
String fieldName,
Case casing
)

In comparison. This allows you to test if objects match any value in an array of values.

Parámetros

  • fieldName - the field to compare.

  • values - array of values to compare with. If null or the empty array is provided the query will never match any results.

  • casing - how casing is handled. Case.INSENSITIVE works only for the Latin-1 characters.

Devuelve

the query object.

Throws

public RealmQuery in (
String fieldName,
)

In comparison. This allows you to test if objects match any value in an array of values.

Parámetros

  • fieldName - the field to compare.

  • values - array of values to compare with. If null or the empty array is provided the query will never match any results.

Devuelve

the query object.

Throws

String fieldName
)

Condition that finds values that are considered "empty" i.e., an empty list, the 0-length string or byte array.

Parámetros

  • fieldName - the field to compare.

Devuelve

the query object.

Throws

String fieldName
)

Condition that finds values that are considered "Not-empty" i.e., a list, a string or a byte array with not-empty values.

Parámetros

  • fieldName - the field to compare.

Devuelve

the query object.

Throws

String fieldName
)

Prueba si un campo no es null . Solo funciona para los campos que permiten nulos.

Parámetros

  • fieldName - el nombre del campo.

Devuelve

the query object.

Throws

String fieldName
)

Tests if a field is null . Only works for nullable fields.

Para las queries de enlaces, si alguna parte de la ruta del enlace es null, se considera que toda la ruta es null; por ejemplo, isNull("linkField.stringField") se considerará null si linkField o linkField.stringField es null .

Parámetros

  • fieldName - el nombre del campo.

Devuelve

the query object.

Throws

public boolean isValid ()

Comprueba si io.realm.RealmQuery sigue siendo válido para su uso, es decir, que la instancia Realm no ha sido cerrada y cualquier io.realm.RealmResults principal sigue siendo válido.

Devuelve

true if still valid to use, false otherwise.

String fieldName,
ObjectId value
)

Less-than comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

String fieldName,
Decimal128 value
)

Less-than comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

String fieldName,
long value
)

Less-than comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

String fieldName,
int value
)

Less-than comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

String fieldName,
ObjectId value
)

Comparación menor o igual a.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

String fieldName,
Decimal128 value
)

Comparación menor o igual a.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

String fieldName,
long value
)

Comparación menor o igual a.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

String fieldName,
int value
)

Comparación menor o igual a.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

public RealmQuery like (
String fieldName,
RealmAny value,
Case casing
)

Condición de que el valor de un campo coincida con la subcadena especificada, con comodines:

  • '*' coincide con [0, n] caracteres unicode

  • '?' matches a single unicode char.

Parámetros

  • fieldName - the field to compare.

  • value - the wildcard string.

  • casing - how to handle casing. Setting this to Case.INSENSITIVE only works for Latin-1 characters.

Devuelve

the query object.

Throws

public RealmQuery like (
String fieldName,
String value,
Case casing
)

Condición de que el valor de un campo coincida con la subcadena especificada, con comodines:

  • '*' coincide con [0, n] caracteres unicode

  • '?' matches a single unicode char.

Parámetros

  • fieldName - the field to compare.

  • value - the wildcard string.

  • casing - how to handle casing. Setting this to Case.INSENSITIVE only works for Latin-1 characters.

Devuelve

the query object.

Throws

public RealmQuery like (
String fieldName,
RealmAny value
)

Condición de que el valor de un campo coincida con la subcadena especificada, con comodines:

  • '*' coincide con [0, n] caracteres unicode

  • '?' matches a single unicode char.

Parámetros

  • fieldName - the field to compare.

  • value - the wildcard string.

Devuelve

the query object.

Throws

public RealmQuery like (
String fieldName,
String value
)

Condición de que el valor de un campo coincida con la subcadena especificada, con comodines:

  • '*' coincide con [0, n] caracteres unicode

  • '?' matches a single unicode char.

Parámetros

  • fieldName - the field to compare.

  • value - the wildcard string.

Devuelve

the query object.

Throws

public RealmQuery limit (
long limit
)

Limita el número de objetos devueltos en caso de que la consulta coincidiera con más objetos. Ten en cuenta que al usar este método en combinación con sort(String) y distinct(String, String...), se ejecutarán en el orden en que fueron añadidos, lo cual puede afectar el resultado final.

Parámetros

  • limit - a limit that is ≥ 1 .

Throws

public Number max (
String fieldName
)

Finds the maximum value of a field.

Parámetros

  • fieldName - el campo para buscar un máximo en. Sólo se admiten campos numéricos.

Devuelve

si no existen objetos o todos tienen null como valor para el campo dado, se devolverá null. En caso contrario, se devuelve el valor máximo. Al determinar el valor máximo, se ignoran los objetos con valores null.

Throws

String fieldName
)

Encuentra el valor máximo de un campo RealmAny.

Parámetros

  • fieldName - the field containing a RealmAny value.

Devuelve

if no objects exist or they all have null as the value for the given RealmAny field, RealmAny.Type.NULL will be returned. Otherwise the maximum RealmAny is returned. When determining the maximum RealmAny, objects with null values are ignored. See the RealmAny documentation for more details on how RealmAny values are compared.

Throws

public Date maximumDate (
String fieldName
)

Finds the maximum value of a field.

Parámetros

  • fieldName - el nombre del campo.

Devuelve

Si no existen objetos o si todos tienen null como valor para el campo de fecha dado, se devolverá null. De lo contrario, se devuelve la fecha máxima. Al determinar la fecha máxima, los objetos con valores null se ignoran.

Throws

public Number min (
String fieldName
)

Finds the minimum value of a field.

Parámetros

  • fieldName - the field to look for a minimum on. Only number fields are supported.

Devuelve

si no existen objetos o todos tienen null como valor para el campo dado, se devolverá null. De lo contrario, se devuelve el valor mínimo. Al determinar el valor mínimo, se ignoran los objetos con valores null.

Throws

String fieldName
)

Busca el valor mínimo de un campo RealmAny.

Parámetros

  • fieldName - the field containing a RealmAny value.

Devuelve

if no objects exist or they all have null as the value for the given RealmAny field, RealmAny.Type.NULL will be returned. Otherwise the minimum RealmAny is returned. When determining the minimum RealmAny, objects with null values are ignored. See the RealmAny documentation for more details on how RealmAny values are compared.

Throws

public Date minimumDate (
String fieldName
)

Finds the minimum value of a field.

Parámetros

  • fieldName - the field name

Devuelve

if no objects exist or they all have null as the value for the given date field, null will be returned. Otherwise the minimum date is returned. When determining the minimum date, objects with null values are ignored.

Throws

public RealmQuery not ()

Negate condition.

Devuelve

the query object.

String fieldName,
ObjectId value
)

Not-equal-to comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

String fieldName,
Decimal128 value
)

Not-equal-to comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

String fieldName,
RealmAny value,
Case casing
)

Not-equal-to comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

  • casing - how casing is handled. Case.INSENSITIVE works only for the Latin-1 characters.

Devuelve

the query object.

Throws

String fieldName,
String value,
Case casing
)

Not-equal-to comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

  • casing - how casing is handled. Case.INSENSITIVE works only for the Latin-1 characters.

Devuelve

the query object.

Throws

String fieldName,
String value
)

Not-equal-to comparison.

Parámetros

  • fieldName - the field to compare.

  • value - the value to compare with.

Devuelve

the query object.

Throws

public RealmQuery or ()

Logical-or two conditions.

Devuelve

the query object.

String predicate,
)

Cree un predicado basado en texto usando el lenguaje de consulta Realm. Este predicado se puede combinar con otros predicados de tipo seguro o sin formato. Acepta valores de Realm como argumentos. Los nombres de clase y propiedad utilizados en el predicado sin formato pueden ser los nombres definidos en las clases Realm Model o los nombres internos definidos utilizando las anotaciones io.realm.annotations.RealmClass o io.realm.annotations.RealmField. Si un nombre de clase o propiedad contiene espacios, éstos deben estar escapados.

Los argumentos se definen en el predicado de cadena como $argument_index, donde $argument_index es un entero decimal que especifica la posición del argumento en la lista. El primer argumento se referencia mediante0$, el segundo mediante1$, etc. Consulte esta documentación para obtener una descripción más detallada del lenguaje de consulta Realm.

Ejemplos:

RealmQuery<Person> query = realm.where(Person.class);
// Simple query
query.rawPredicate("name = 'Jane'");
// Spaces in property name
query.rawPredicate("my\ property = 'Jane'");
// Multiple predicates
query.rawPredicate("name = 'Jane' OR name = 'John'")
// Collection queries
query.rawPredicate("children.@count > 3")
query.rawPredicate("ALL children.age > 18")
// Sub queries
query.rawPredicate("SUBQUERY(children, $child, $child.age > 21 AND $child.gender = 'male').@count > 0");
// Sort, Distinct, Limit
query.rawPredicate("name = 'Jane' SORT(lastName ASC) DISTINCT(city) LIMIT(5)");
// Arguments
query.rawPredicate("name = $0 AND age > $1", "Jane", 18);

Parámetros

  • predicate - Un predicado de Realm Query Language.

  • arguments - Realm values for the predicate.

Throws

public RealmQuery sort (
java.lang.String[] fieldNames,
io.realm.Sort[] sortOrders
)

Sorts the query result by the specific field names in the provided orders. Later fields will only be used if the previous field values are equal.Sorting is currently limited to character sets in 'Latin Basic', 'Latin Supplement', 'Latin Extended A', 'Latin Extended B' (UTF-8 range 0-591). For other character sets, sorting will have no effect.

Parámetros

  • fieldNames - an array of field names to sort by.

  • sortOrders - cómo ordenar los nombres de los campos.

Throws

public RealmQuery sort (
String fieldName1,
Sort sortOrder1,
String fieldName2,
Sort sortOrder2
)

Sorts the query result by the specific field names in the provided orders. fieldName2 is only used in case of equal values in fieldName1 .

La ordenación está limitada actualmente a los conjuntos de caracteres «Latín Básico», «Latín Suplementario», «Latín Extendido A» y «Latín Extendido B» (rango UTF-8 0-591). Para otros conjuntos de caracteres, la ordenación no tendrá efecto.

Parámetros

  • fieldName1 - primer nombre de campo

  • sortOrder1 - sort order for first field

  • fieldName2 - second field name

  • sortOrder2 - sort order for second field

Throws

public RealmQuery sort (
String fieldName,
Sort sortOrder
)

Sorts the query result by the specified field name and order.Sorting is currently limited to character sets in 'Latin Basic', 'Latin Supplement', 'Latin Extended A', 'Latin Extended B' (UTF-8 range 0-591). For other character sets, sorting will have no effect.

Parámetros

  • fieldName - el nombre del campo por el que ordenar.

  • sortOrder - cómo ordenar los resultados.

Throws

public RealmQuery sort (
String fieldName
)

Sorts the query result by the specific field name in ascending order.Sorting is currently limited to character sets in 'Latin Basic', 'Latin Supplement', 'Latin Extended A', 'Latin Extended B' (UTF-8 range 0-591). For other character sets, sorting will have no effect.

Parámetros

  • fieldName - el nombre del campo por el que ordenar.

Throws

public Number sum (
String fieldName
)

Calculates the sum of a given field.

Parámetros

  • fieldName - the field to sum. Only number and RealmAny fields are supported.

Devuelve

the sum of fields of the matching objects. If no objects exist or they all have null as the value for the given field, 0 will be returned. When computing the sum, objects with null values are ignored. When applied to a RealmAny field, only numeric values will be summed up (Byte/Integer/Integer/Long/Float/Double/Decimal128) and the returning type will be Decimal128 .

Throws

Volver

RealmObjectSchema.Function