I am trying to do an filtered replication with TouchDB-Android and everything seems fine in the beginning and everything looks fine until I start deleting stuff on the serverside. If some documents get deleted server side, those documents doesn't get deleted locally. So my question is if there is some way to make this work or if this is intended? I tried doing my sync without a filter function and then all the documents got deleted correctly on the mobile as it should.
Deleting documents can be tricky in the context of filtered replications. For example, let's assume you have a document that has aworker_id field, and you setup a filtered replication to only pull documents when the worker_id equals a certain value.
When one of these documents is deleted, it will not get sync'd in the pull replication! Since the filter function will look for a document with a specific worker_id, and the deleted document won't contain any worker_id, it will fail the filter function and therefore not be sync'd.
This can be fixed by deleting documents in a different way. Since a document is considered deleted as long as it has the special_deleted field, it is possible to delete the document while still retaining the worker_id field. Instead of using the DELETE verb, you will instead want to use the PUT verb. You will definitely need to set the _deleted field, in order for the document to be considered deleted. You can then either retain the field(s) that you need for filtered replication, like the worker_id field, or you can retain all of the fields in the original document.
--
You received this message because you are subscribed to the Google Groups "Mobile Couchbase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchba...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.