Quantcast
Channel: Active questions tagged mongodb-atlas - Stack Overflow
Viewing all articles
Browse latest Browse all 271

Schema validation failed in Realm/Atlas due to an unknown type

$
0
0

I have a Kotlin Multiplatform app that I'm trying to get to work with Realm/Atlas. When I try to do a Realm.open(it) it says:

IllegalStateException@29576} "java.lang.IllegalStateException:[RLM_ERR_SCHEMA_VALIDATION_FAILED]: Schema validation failed due tothe following errors: Property 'PelletInsertionVisit.pelletMapAsList'of type 'array' has unknown object type 'PelletToNumberUsedMapEntry'

I have multiple classes but the ones germane to this are the following:

class PelletInsertionVisit : RealmObject {@PrimaryKeyvar _id: String = ""var visitDate = LocalDateTime.now().toEpochSecond(ZoneOffset.UTC)var pelletsUsed: RealmList<Pellet> = realmListOf()var pelletMapAsList: RealmList<PelletToNumberUsedMapEntry> = realmListOf() //Maps pellet name to number of pellets of that type usedvar signedInUser: String = "UNKNOWN" //User name of user performing the updateoverride fun toString(): String {    return "PelletInsertionVisit(visitDate=$visitDate, pelletsUsed=$pelletsUsed, pelletMap=$pelletMapAsList, signedInUserUserName='$signedInUser')"}}

And this one:

class PelletToNumberUsedMapEntry : EmbeddedRealmObject {var pelletKey: String = "NOTSET"var numberUsed: Int = 0}

Right before I call the Realm.open(it) I execute this code:

    private fun setupRealmSync() {    val user = runBlocking { appServiceInstance.currentUser }    val config = user?.let {        SyncConfiguration            .Builder(                it,                setOf(UserAccount::class,Pellet::class, PelletInsertionVisit::class, PelletLot::class, Patient::class,                    Practice::class )            )            .initialSubscriptions(rerunOnOpen = true) { realms ->                add(                    realms.query<PelletInsertionVisit>(),                    name = "Pellet Insertion Visit info",                       updateExisting = true                )                add(realms.query<PelletLot>(), name = "Pellet info", updateExisting = true)                add(realms.query<Patient>(), name = "Patient info", updateExisting = true)                add(realms.query<Practice>(), name = "Practice info", updateExisting = true)                add(realms.query<UserAccount>(), name = "UserAccount info", updateExisting = true)            }            .build()    }

So, PelletInsertionVisit is added (and I see it in MongoDB Compass), but it's not liking the other class. I thought that it being embedded would suffice, but is that the issue?


Viewing all articles
Browse latest Browse all 271

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>