vicpinm / Kotlin-Realm-Extensions

Kotlin extensions to simplify Realm API.
Apache License 2.0
535 stars 53 forks source link

Mutliple equalTo #43

Closed AndroFlo closed 6 years ago

AndroFlo commented 6 years ago

Hello, I would like avoid the filter{} like my sample val documentsNotGetCount = RDocument().query { equalToValue("mission.id", mission?.id!! ) }.filter { rDocument -> !rDocument.is_get }.count()

Is it possible ?

Than,k's

vicpinm commented 6 years ago

Hi @AndroFlo, you should be able to do something like equaltToValue().and().equalTovalue() etc.

AndroFlo commented 6 years ago

Yes thank's @vicpinm it works with equalTo not with equalToValue

val documentsNotGetCount = RDocument().query {

        equalTo("mission.id", mission?.id!!)
        and()
        equalTo("is_get",false)

    }.count()
vicpinm commented 6 years ago

@AndroFlo equalToValue is only for Int and Long parameters. In your case, your "is_get" parameter is boolean, so you should use equalTo. EqualTo() method has problems with number types in kotlin, and you can get an overload resolution ambiguity error. This is the reason for what I made equalToValue method, to avoid this error, only for cases when your parameter is a number.