I do not understand why I'm getting this error. I'm doing everything in a write transaction right?
activeSchoolClassNotNull { activeSchoolClass ->
val schoolSubjects = ocjeneSkoleScraper.getSubjects()
realm.write {
activeSchoolClass.schoolSubjects = schoolSubjects.toRealmList()
copyToRealm(activeSchoolClass, updatePolicy = UpdatePolicy.ALL)
this@SchoolRepositoryImpl.activeSchoolClass = activeSchoolClass
}
}
Can anyone tell me what I'm doing wrong?
The problem was that I needed to get the latest object from realm before modifying it.
realm.write {
val latestObj = findLatest(obj)
latestObj.someProperty = "changed"
copyToRealm(latestObj)
}