In operator does not work in realm.query in this function:
suspend fun getRestaurantsProcessedOrdersWithThrowAndroid(): CommonFlow<List> {
realm.syncSession.downloadAllServerChanges()
val userId = appService.currentUser
if(appService.currentUser != null) {
val restaurantsIds = realm.query<Restaurant>("userID = $0", userId!!.id).find().map { it.getID() }
val queryValues = restaurantsIds.joinToString(separator = ",", prefix = "{", postfix = "}")
return realm.query<ProcessedOrder>(
"restaurantID IN $0", queryValues
).asFlow()
.map {
it.list
}.asCommonFlow()
}
else{
throw Exception("user not logged in")
}
}
I have tried with listOf("id,“id”,“id”) and still does not work. Any idea?
Have a great day!
Im using this function that works. So i guess your are missing the “uuid(” part
fun createQueryOfIds(ids: List): String {
val idsQueryString = ids.joinToRealmQuery()
return “id IN $idsQueryString”
}
fun List.joinToRealmQuery(): String {
return this.joinToString(prefix = “{”, postfix = “}”, separator = ", ") {
“uuid(${
it.toString().uppercase()
})”
}
}
For me it worked like this:
val restaurantsIds = realm.query(“userID = $0”, userId!!.id).find().map { it.getID() }
val queryValues = restaurantsIds.joinToString(“‘,’”)
return realm.query(
“restaurantID IN {$0}”, queryValues
)
system
(system)
Closed
4
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.