https://kotlinlang.org logo
#realm
Title
# realm
a

AKlam

07/29/2022, 3:07 PM
Hi 👋 I'm trying to use kotlin realm sdk for Flexible Sync. For standard Realm object like this it's work perfect:
Copy code
open class SomeClass(
    @PrimaryKey var _id: String = "",
    var _partition: String = "",
    var card: String? = null,
) : RealmObject
But for embedded object
Copy code
open class SomeClass(
    @PrimaryKey var _id: String = "",
    var _partition: String = "",
    var card: Card? = null,
) : RealmObject 

open class Card(
    var cardNumber: String? = null,
    var isPrivateCard: Boolean? = null,
    var uuid: String? = null
) : EmbeddedRealmObject
I can't pass Card:class to SyncConfiguration like that, cause schema only takes set of RealmObject, not BaseRealmObject.
Copy code
SyncConfiguration.Builder(
        user = getCurrentUser(),
        schema = setOf(SomeClass::class, Card::class)
    )
But if I add only SomeClass:class
Copy code
SyncConfiguration.Builder(
        user = getCurrentUser(),
        schema = setOf(SomeClass::class, Card::class)
    )
I will recieve the following error and app crash:
Copy code
Caused by: io.realm.kotlin.internal.interop.RealmCoreLogicException: [18]: Schema validation failed due to the following errors:
2022-07-29 17:07:53.490 11177-11177/my.app.dev E/AndroidRuntime: - Property 'SomeClass.card' of type 'object' has unknown object type 'Card'
Any ideas?
15 Views