Document deletion and pull replication

51 views
Skip to first unread message

Nicolas Lapomarda

unread,
Mar 28, 2014, 11:59:24 AM3/28/14
to mobile-c...@googlegroups.com
Hey,

My users are working with CBL documents on their devices that they acquired via a pull replication from a Sync Gateway channel.
I have a use case where a user might want to locally delete the documents pertaining to a given channel.

What is the preferred way of achieving this?
- Leverage the sync function to revoke access for this channel, so the documents disappear (doc.isGone == YES)?
- Call -[CBLDocument deleteDocument:] on all the documents of the channel?
- Call -[CBLDocument purgeDocument:] on all the documents of the channel?
- Another schenario?

Note 1: I need the documents to be physically deleted from the device. They contains large-ish attachments which we want gone.
Note 2: The use case also should allow the use to fetch those documents (and attachments) again at a later time. (How?)

Kind regards,
Nicolas

Jens Alfke

unread,
Mar 28, 2014, 2:16:15 PM3/28/14
to mobile-c...@googlegroups.com

On Mar 28, 2014, at 8:59 AM, Nicolas Lapomarda <ni...@conceited.net> wrote:

- Call -[CBLDocument purgeDocument:] on all the documents of the channel?

This.

Note 1: I need the documents to be physically deleted from the device. They contains large-ish attachments which we want gone.

Compact the database after purging, which will delete the attachments.

Note 2: The use case also should allow the use to fetch those documents (and attachments) again at a later time. (How?)

Create a new pull CBLReplication and set its documentIDs property to the document(s) you want to re-fetch.

(Actually there might be a problem with this the second time you try it — the first time you run this replication it will fetch the docs, but then it will remember a checkpoint at the current sequence of the remote db. The second time you run it, it will only look at revisions newer than that checkpoint, so if those docs haven’t changed they won’t be replicated. Hm. What we need is an API to reset a replication by clearing its checkpoint.
A workaround is to add a bogus random doc ID to the array of doc IDs to fetch. This will cause the replication to have a different checkpoint ID every time.)

—Jens

Nicolas Lapomarda

unread,
Apr 11, 2014, 1:09:28 AM4/11/14
to mobile-c...@googlegroups.com
Thanks Jens.

The client may not actually know which documentIDs to refetch (in my case, the documents are simply a Sync Gateway channel). The user subscribed to that channel, then unsubscribed, then subscribed again. Each change in subscription should reflect a change on whether the documents are physically present on the device of not.

I could persist the documentIDs somehow, but if the user deletes the client app entirely, I won't have that info the next time they install it.

Any idea how to work around this?

Nico

--
You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/2996704C-1A3D-49A8-B1D9-497F3BC94251%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages