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/680f26e8-3ea7-4b93-b0d0-a5196de86052%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to