Why can I not see in Couchbase Lite that a document has been removed from sync?


I have changed my sync. formula slightly so that a specific type of documents that previously was added to the “!” channel now is not added to that channel any more. I have taken the db offline, resync’ed it, and online again.

When I sync. with the app then all of the existing documents of that type is still found in the app… Why is that? What should I do to remove them from the app if they have already been sync’ed to the app before my change to the sync. formula on the sync. gateway?

Running Couchbase Community edition 6.6, Sync. gateway 2.7 (probably should upgrade…) and CB Lite 2.8.4.

Resync doesn’t assign new sequence numbers to documents (yet… I think that’s a future opt-in enhancement).

If you want to remove a doc from a channel, you can write an update to it, which allows it to run through your new sync function and get a new sequence for clients to pull.

Ah, Ok. So when the documents get updated they will be removed from the app?

Good to know - and that may actually happen relatively quickly in this app anyway.


If the doc was explicitly removed from a channel, yes clients will recieve a removal notification and I believe it will be purged from the device (or at least a CBL notification is sent telling the app it was removed) - I’m not 100% sure on the details on the client side.

There’s another upcoming enhancement that expands on this functionality futher, to remove documents based on indirect access removal too (for example if a user lost access to a doc via a role removal).

I had this code - that is now commented out:

// All users are available (for stats)
//                if (doc.type == 'User' && doc.deleted != true) {
//                    _log('User doc, id: ' + (doc._id || 'no id!'));
//                    channel('!');
//                 }

Not sure if that covers “explicitly removed”?

I’ll do a test tomorrow where I change a couple of documents to see if they are then removed from the app.

Yup that should work - “explicitly removed” is a bit ambigouous I admit. I meant the channel is removed (not set on a mutation) from the doc, rather than something like the replicating user being removed from the channel.

Hmmm… If I change (or even delete) one of the ‘User’ documents on the server then it doesn’t replicate to the app. I tried a similar change of an attribute on another type of doc - and it replicates right away…

What am I missing…? Do I need to do a resync on the sync. gateway again???

Ok, I have now tried to resync the sync. gateway again (and yesterday I upgraded to latest SG 2.8.2 before the tests today…

It doesn’t send any message to the replicator in the app - but it does for e.g. an “Article” type of doc.

So I must be missing something here…