Cancel delete of Sync'd Object

What’s the process for handling a sync’d object that’s deleted, but the Rules are set to prevent a write.

In other words, in the console, the Define Permissions for the App are set to write: false

And then in the app data is deleted

do {
    try realm.write {
} catch let err as NSError {

The end result is while an error is thrown, which is caught by the catch block, the task object is still deleted locally.

How does one roll that back or prevent the object from being deleted locally?

Or is there a totally different approach?

Hi @Jay, unfortunately, the SDKs don’t know whether the user is allowed to sync writes to the realm.

I think this means that the app has to figure that out. I’d suggest doing it when opening the Realm.

If the sync-write rule is complex and/or needs access to other data, then I’d suggest implementing the logic in a Realm function which can then be called by both the sync-write rule and your app.