Error when trying to remove relationship of schemas

Context

Mongo Object Model reports that I have some InvalidSchemaError. So I think the problem regarding to my relationships between documents

Here is my documents

  • document Customers to Events as One-to-Many with Customers.events ( objectID array ) to Events._id
  • document Events to Customer as One-to-One with Events.customer_id to Customers._id

Tried Solutions

  1. I tried to remove field customer_id from required in document Events, but it poped up this error

  1. I tried to delete the One-to-One relationship in Events but it still generates the same error.

  2. I also tried to delete the relationships One-to-many in Customers and events field at the same time, and it also generates the error

I don’t know whether I delete the relationship correctly. I opened the “Expand relationships”, neither just clears the box nor changes to “{}” works

Hi Phu,

Is this the error you’re referring to?

Failed to convert MongoDB document with configured schema during initial sync

This means that a document exists which did not comply with your current Sync Schema - the namespace and the document id will be specified in the error log within your Realm Application Logs.

The error details will show you what the problem was, for instance if your sync configuration has specified the partition key to be a field named “user_id” and a document is created without a value for this field, it will throw the error above and said document will not be syncable until it is corrected.

To correct this document and make it syncable you will need to issue a replace() command from MongoShell, or update it using Atlas Data Explorer in order to bring it in compliance with the sync schema.

I don’t know whether I delete the relationship correctly. I opened the “Expand relationships”, neither just clears the box nor changes to “{}” works

Regarding this issue, please try first creating Rules for your collections and then try making the changes to the relationships.

If you’re still getting an error try making the change using the latest realm-cli version:

  1. realm-cli pull your app to your machine
  2. In the output directory, modify the relationship.json files of both collections to {}
  3. realm-cli push the updated local app

Regards