If you remove or delete a document via SDK or directly couchbase server, the oldDoc will be null. You don’t have to do anything specific in terms of putting deleted documents into channel - the SGW will take care of it for you. The document is already in a channel and would now be updated with the _deleted flag as true.
This test would be the check to see if document is removed.
function isRemoved() {
return( isDelete() && oldDoc == null);
}
So this is all you would have to do in your sync function …for example
function sync(doc, oldDoc) {
/* sanity check */
// check if document was removed from server or via SDK
// In this case, just return
if (isRemoved()) {
return;
}
// rest of your sync function ...