I'm facing off an issue due to companion object inside a Realm entity.
Example:
// Entity
open class MyEntity(
@PrimaryKey
var id: String? = "",
// other fields...
): RealmObject() {
companion object{
fun clean(realm: Realm) {
realm.beginTransaction()
realm.where(MyEntity::class.java).findAll().deleteAllFromRealm()
realm.commitTransaction()
}
}
}
// Migration code
schema
.create(MyEntity.class.getSimpleName())
.addField("id", String.class, FieldAttribute.PRIMARY_KEY);
addMissingFields(schema, MyEntity.class);
When migration is executed, I get the following exception:
Realm doesn't support this field type: Companion(class com.example.MyEntity$Companion)
I'd like to know how ignore the companion object
from Realm scan.