One possible reason why the document is empty: It looks like your document has a “channels” property is that correct? In CBL did you set your propertiesToSaveForDeletion to persist the “channels” property after deletion? What I found on iOS is by default (if propertiesToSaveForDeletion is not set) when a doc is deleted the only properties that are send to the sync gateway are these : _deleted, _id, _rev, _revisions.
Sync gateway docs on handling deletions:
Validation checks often need to treat deletions specially, because a deletion is just a revision with a
"_deleted": true
property and usually nothing else. Many types of validations won’t work on a deletion because of the missing properties — for example, a check for a required property, or a check that a property value doesn’t change. You’ll need to skip such checks ifdoc._deleted
is true.
Sync Function API Reference | Couchbase Docs
requireAccess(oldDoc.channels); // ← Change this?
I think this would work but what I mentioned above might be the cause. I don’t know if removing this would be a security issue?