After deleting object in Realm studio, if our server tries to write the object again it gets Attempting to create an object of type ' with an existing primary key value error


So if we delete an object with say primary key ‘123’ and then try to write an object with that same key afterwards we get the error that its trying to write an object with an existing primary key.

Then if we try write it again it goes through.

So basically we have to call the realm.write() twice on the object to get it to write to the realm, because the first time it tries to write after a delete it thinks the object still exists and only on the second cal does it realise it doesn’t exist


Deleting an object in Studio takes time to synchronize it with ROS. Then your client needs to download the changes to notice the object has been deleted. I imagine what’s happening is that you’re trying to do the first write immediately after the deletion before the changes have been synchronized, then, by the time you retry it, the deletion has been propagated to your client.