Changing Sync Permission Rules

In the Realm UI, I can’t edit the sync permissions (Development & Production modes) unless I terminate sync and re-enable it.

While building the application, this is fine. However, terminating and re-enabling Sync also invalidates my realm file on the client, and I have to delete the app and re-install it.

I can reason around why you have to terminate sync to edit the permissions, but it feels very scary to have an irrecoverable realm file that I don’t have access to (as far as I know) in the app that I can delete on behalf of the user and re-sign in fresh.

Am I missing something obvious?

Here is the error log:

That’s correct although you generally wouldn’t be changing the permissions structure once you enable sync. In production, we would recommend using custom user data or function as your permission structure and then you can dynamically add partitions to be readable or writable in a document or custom user data that the system checks to determine access. That way you don’t need to terminate sync but can change access.

https://docs.mongodb.com/realm/sync/permissions/#function-rules