So here’s the thing. I have troubles with an array/realmList type. I want to define a required field for the array/RealmList type. I’ve defined a required “array” field in my Mongo Atlas schema. And I’ve set a default value for that same field in the RealmObject model class. But whenever I try to launch an android app, I’ve been getting this same error in the logs:
ending session with error: failed to add app schema for ns=‘mongodb-atlas.diaries.Diary’ for new top-level schema “Diary”: sync-incompatible app schema for the same collection already exists. This app schema is incompatible with error: “array property "imagess" must be optional to be sync-compatible”. To continue, delete the app schema in Atlas App Services, or update it to match the app schema defined on the device (ProtocolErrorCode=225)
This is my schema:
{
"title": "Diary",
"bsonType": "object",
"required": [
"_id",
"ownerId",
"mood",
"title",
"description",
"images",
"imagess",
"date"
],
"properties": {
"_id": {
"bsonType": "objectId"
},
"ownerId": {
"bsonType": "string"
},
"mood": {
"bsonType": "string"
},
"title": {
"bsonType": "string"
},
"description": {
"bsonType": "string"
},
"images": {
"bsonType": "string"
},
"imagess": {
"bsonType": "array",
"items": {
"bsonType": "string"
}
},
"date": {
"bsonType": "date"
}
}
}
This is my model class:
open class Diary constructor(
@PrimaryKey
var _id: ObjectId,
var ownerId: String,
var mood: String,
var title: String,
var description: String,
var images: String,
var imagess: RealmList<String>,
var date: RealmInstant,
) : RealmObject {
constructor() : this(
_id = ObjectId.create(),
ownerId = "",
mood = Mood.Neutral.name,
title = "",
description = "",
images = "",
imagess = realmListOf("stev", "stev2"),
date = RealmInstant.from(System.currentTimeMillis(), 0),
)
}