Piotr Romanowicz
01/18/2022, 3:38 PMNabil
01/18/2022, 3:44 PMPiotr Romanowicz
01/18/2022, 7:36 PMclass Group : RealmObject(){
@PrimaryKey
var id:String=""
var users:RealmList<User>
}
class User : RealmObject(){
@PrimaryKey
var id:String=""
var age:Int?=null
var name:String?=null
}
Usage:
groupIntance.users.where()...
Unforunately at the moment the multiplatform RealmList is not Queryable<T>
at the momentNabil
01/19/2022, 2:13 AMGroup
but specify a filter by the RealmList as follow:
val results: RealmResults<Group> = realm.objects(Group::class)
.query("users.age > $0 AND users.name BEGINSWITH $1", 19, "user")
Obviously you can also query directly User
val result_users: RealmResults<User> = realm.objects(User::class)
.query("age > $0 AND name BEGINSWITH $1", 19, "user")
see https://github.com/realm/realm-kotlin#query check more query examples here https://docs.mongodb.com/realm/sdk/node/advanced/query-engine/#comparison-operatorsPiotr Romanowicz
01/19/2022, 8:22 AMval result_users: RealmResults<User> = realm.objects(User::class)
.query("age > $0 AND name BEGINSWITH $1 AND id IN $2", 19, "user",group.users)
But this is not working anyhow.Nabil
01/19/2022, 12:44 PMwe want users that are in the list of specified groupThis could be possible using LinkingObjects which are not yet implemented in Realm Kotlin One work around could be to first query the needed `Group`s then apply Kotlin Collections filter to iterate over each group users to filter out the one that satisfies your conditions
Piotr Romanowicz
01/19/2022, 1:32 PM