My Realm app is failing to sync, and I’m getting the following error:
ERROR: Connection[1]: Session[1]: Failed to transform received changeset: Schema mismatch: Property ‘children’ in class ‘Folder’ is nullable on one side and not on the other.
In my app, Folders
can have many, and belong to many Folders
. I’m not sure what this error means by “nullable on one side and not on the other”?
MORE CONTEXT:
This is the config I’m using when opening a Realm connection:
const config = {
schema: [Schema.Folder, Schema.Note],
schemaVersion: 2.2,
path: `${app.getPath('userData')}/${this.app.currentUser.id}/default.realm`,
sync: {
user: this.app.currentUser,
partitionValue: this.app.currentUser.id,
existingRealmFileBehavior: {
type: "openImmediately"
},
newRealmFileBehavior: {
type: "openImmediately"
}
}
}
And as for the Schema.Folder
and Schema.Notes
it’s referencing, those are defined as this:
const Folder = {
name: "Folder",
primaryKey: "_id",
_partition: "string?",
properties: {
_id: "string",
name: { type: "string", default: "Untitled Folder" },
folder_id: { type: "string?", default: "" },
is_collapsed: { type: "bool", default: true },
children: {
type: "list",
objectType: "string"
},
notes: "Note[]",
created_at: "date",
updated_at: "date?",
deleted_at: "date?",
}
}
const Note = {
name: "Note",
"primaryKey": "_id",
_partition: "string?",
properties: {
_id: "string", // uuid
body: { type: "string?", default: "" },
preview: "string?",
is_pinned: { type: "bool", default: false },
folder: {
type: "linkingObjects",
objectType: "Folder",
property: "notes"
},
created_at: "date",
updated_at: "date?",
deleted_at: "date?",
margins: { type: "bool", default: false },
}
}