Hi Jens,
I was just working on tackling this issue again as I never got it going. I
was hoping you could shed some light into how I could fetch a deleted
document and recover its data. I see in the raw db.sqlite file that the
JSON data is there for the document, but it's marked as deleted. If I ask
the document for its current revision, it comes back nil. I thought I
might be able to get the current revision and then set the isDeleted flag
to false or create a new revision that's not deleted and give it the
properties from the deleted revision.
Is this possible?
Thanks,
Brendan
On Tuesday, September 13, 2016 at 11:30:47 PM UTC-6, Brendan Duddridge
wrote:
>
> Hi,
>
> I've written a small bit of code to try and restore deleted documents, but
> I'm coming up a bit empty.
>
> Here's what I've got so far:
>
> - (IBAction)recoverDeletedDocs:(id)sender {
>
> CBLQuery *allDocsQuery = [self.currentDatabase
> createAllDocumentsQuery];
>
> allDocsQuery.allDocsMode = kCBLIncludeDeleted;
>
>
> CBLQueryEnumerator *enumerator = [allDocsQuery run:nil];
>
> for (CBLQueryRow *row in enumerator) {
>
> if (row.document.isDeleted) {
>
> TFFLog(@"revisions: %@", [row.document
> getRevisionHistory:nil]);
>
> TFFLog(@"row.key: %@, value: %@", row.key, row.
> value);
>
> CBLRevision *revision = row.document.
> currentRevision;
>
> if (revision) {
>
> CBLSavedRevision *parent = revision.
> parentRevision;
>
> if (parent) {
>
> TFFLog(@"properties: %@", parent.
> properties);
>
> CBLUnsavedRevision *unsaved = [parent
> createRevision];
>
> unsaved.userProperties = parent.
> userProperties;
>
> [unsaved save:nil];
>
> }
>
>
>
> }
>
> }
>
> }
>
>
>
> }
>
>
>
> The problem is that the revision on the document is nil. The document
> properties are also empty.
>
> Given a deleted document, how do I get the previous revision so that I can
> create a new revision and recover the deleted document?
>
> Thanks
>
> Brendan
>
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/mobile-couchbase/a776227f-ecc6-49b7-ac88-012ea549058d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.