John O'Reilly
05/24/2023, 5:54 PMchrmelchior
05/25/2023, 11:09 AMThiago Delgado
06/09/2023, 1:40 PMChristos Savlidis
07/27/2023, 1:51 PMRealm.open(getRealmUnEncryptedConfig())
every time is correctGrzegorz Gajewski
07/28/2023, 2:14 PMThe Kotlin SDK does not provide the ability to set and access a default realm in your application. Since you can now share realms, objects, and results across threads, you can rely on a global singleton instead.
So I went with global singleton. But I don’t think this works like I thought it would (similar to room) as now I’m getting:
java.lang.IllegalStateException: [RLM_ERR_WRONG_TRANSACTION_STATE]: The Realm is already in a write transaction
I have a background sync that might write at any given moment, should I open another Realm for that in this case to avoid this crash?John O'Reilly
07/30/2023, 12:16 PMDaniel
07/31/2023, 7:56 PMappService.currentUser
is null for some users after they already login?
this will cause the app to crash because I really dont know a good way or flow to handle when it is null, I dont even know how its possible to be null, because I do not delete the users nor the token refresh expires.
the code:
fun getUserProfile(): CommonFlow<UserInfo?> {
val userId = appService.currentUser!!.id
val user = realm.query<UserInfo>("_id = $0", userId).asFlow().map {
it.list.firstOrNull()
}.asCommonFlow()
return user
}
how is it possible to be null?Grzegorz Gajewski
08/01/2023, 7:23 AMOR
between two subqueries? I have a big query with subqueries build like this:
var query = query<Model>("id == $0", id)
if (otherModelId != null) {
query = query.query("otherModel.id == $0", otherModelId)
}
if (markedOnly) {
query = query("flagged == $0", true)
}
And now I need to add OR to the top level query.Thiago Delgado
08/09/2023, 11:17 PMGrzegorz Gajewski
08/10/2023, 9:26 AMThiago Delgado
08/10/2023, 8:45 PMGrzegorz Gajewski
08/25/2023, 11:30 AM1.7.0
and latest 1.10.2
. When I remove the code to collect the flow and run GC manually it drops (but only in 1.7.0
). What am I missing here? What are the strategies that we can use today to keep active realm versions low?
object Singleton {
val config = RealmConfiguration.create(schema = setOf(Item::class))
val realm = Realm.open(config)
}
class Item : RealmObject {
@PrimaryKey
var _id: ObjectId = ObjectId()
var isComplete: Boolean = false
var summary: String = ""
var owner_id: String = ""
}
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val objectsCount = mutableStateOf(0L)
val versionsCount = mutableStateOf(realm.getNumberOfActiveVersions())
setContent {
RealmTestTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
Greeting(objectsCount.value.toString(), versionsCount.value.toString(), onClick = {
lifecycleScope.launch(<http://Dispatchers.IO|Dispatchers.IO>) {
repeat(100) {
realm.write {
copyToRealm(Item().apply {
summary = "Do the laundry"
isComplete = false
})
}
delay(10)
versionsCount.value = realm.getNumberOfActiveVersions()
}
}
})
}
}
}
realm
.query<Item>()
.asFlow()
.onEach {
val summaries = it.list.map { it.summary }
objectsCount.value = summaries.count().toLong()
}
.flowOn(<http://Dispatchers.IO|Dispatchers.IO>)
.launchIn(lifecycleScope)
}
}
@Composable
fun Greeting(objectsCount: String, activeVersions: String, modifier: Modifier = Modifier, onClick: () -> Unit) {
Column() {
Text(
text = "Objects $objectsCount",
modifier = modifier
)
Text(
text = "Active versions $activeVersions",
modifier = modifier
)
Button(onClick = onClick) {
Text(text = "Insert 100 items")
}
}
}
benkuly
10/12/2023, 3:20 PMdephinera
10/17/2023, 8:23 AMChristopher Mederos
10/20/2023, 12:54 AM"progressMinutes > $0 AND assignee == $1", 1, "Alex"
Ideally, is there a similar syntax available like "progressMinutes > $0 AND assignee == $1", queryParams.values
?BaBeStudios
11/08/2023, 12:07 PMCaused by: java.lang.ClassNotFoundException: Didn't find class "java.time.Clock" on path: DexPathList[[zip file "/data/app/[...]split_config.xxxhdpi.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
java.lang.ClassLoader.loadClass(ClassLoader.java:380)
java.lang.ClassLoader.loadClass(ClassLoader.java:312)
io.realm.kotlin.internal.platform.SystemUtilsKt.currentTime(SystemUtils.kt:32)
io.realm.kotlin.types.RealmInstant$Companion.now(RealmInstant.kt:87)
Clock was added in API 26 for Android. Is there a way to mitigate this, or is the minimum Android SDK version for the Kotlin SDK effectively API level 26? I'm writing this before looking into replacing RealmInstant or the call to systemUTC(), that causes the Exception.chrmelchior
12/04/2023, 1:26 PMChristopher Mederos
12/20/2023, 6:18 AMDaniel
02/07/2024, 11:31 PMsuspend fun getRestaurantsProcessedOrdersWithThrowAndroid(): CommonFlow<List<ProcessedOrder>> {
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")...
Do you know why?Simon
04/14/2024, 6:10 AMJohn O'Reilly
04/15/2024, 11:57 AMHacine Mohamed Abdelhakim
04/23/2024, 2:16 PMZsolt.bertalan
05/22/2024, 4:19 PMChristopher Mederos
06/28/2024, 5:22 AMEduardo Ruesta
08/19/2024, 7:50 PMDaniel
10/22/2024, 7:00 PMEduardo Ruesta
10/23/2024, 3:52 PMDaniel
10/28/2024, 6:57 PMPiotr Romanowicz
01/20/2025, 2:15 PM