On Oct 22, 2017, at 11:37 PM, Brendan Duddridge <bren...@gmail.com> wrote:But I don't want the non-deleted documents to be fetched. Because if I have 10,000 documents and 1 has been deleted somewhere, I don't want to have to loop through all 10,000 to find the one deleted one.
Also, if I call existingLocalDocumentWithID, will it return a document even if it's deleted? Hopefully so. I need this because I'm hoping to get an array of dictionaries that represent the deleted documents. Then let the user pick which ones they want to restore. I'll fetch the document given the ID and then get its leaf revisions, then restore it.
You mean existingDocumentWithID, right? (Local docs are different.) Yes, I’m pretty sure it returns the document (though I’m getting rusty on 1.x so don’t take that as gospel.)
Good point. There isn’t really a solution for this. But I think the overhead shouldn’t be too high because the query isn’t fetching the body of each document, just the metadata. Have you experienced this being slow or are you just worried?
for (CBLQueryRow *row in deletedRows) {
if (progress.isCancelled) {
TFFLog(@"Fetch deleted documents cancelled...");
break;
}
NSArray *leafRevisions = [row.document getLeafRevisions:&error];
CBLSavedRevision *revision = [leafRevisions firstObject];
if (revision && !error && revision.propertiesAvailable) {
CBLJSONDict *properties = revision.properties;
if ([(NSNumber *)properties[@"_deleted"] isEqual:@1]) {
revision = revision.parentRevision;
if (revision.propertiesAvailable) {
properties = revision.properties;
} else {
properties = nil;
}
}
NSString *objectType = properties[@"type"];
if (objectType.length > 0 && properties.count > 0) {
NSMutableArray *revisionsForType = deletedDocs[objectType];
if (!revisionsForType) {
revisionsForType = [NSMutableArray array];
deletedDocs[objectType] = revisionsForType;
}
[revisionsForType addObject:properties];
}
}
On Oct 24, 2017, at 8:12 PM, Brendan Duddridge <bren...@gmail.com> wrote:if (revision && !error && revision.propertiesAvailable) {
CBLJSONDict *properties = revision.properties;
if ([(NSNumber *)properties[@"_deleted"] isEqual:@1]) {
You can replace this with justif (revision.isDeletion) {—Jens
CBLSavedRevision *revision = [leafRevisions firstObject];
if (revision && !error) {
CBLJSONDict *properties = nil;
if (revision.isDeletion) {
revision = revision.parentRevision;
if (revision.propertiesAvailable) {
properties = revision.properties;
}
} else if (revision.propertiesAvailable) {
properties = revision.properties;
Are this revision's properties available? They may not be if the revision is an ancestor and
either the database has been compacted, or the revision was replicated from another db.
On Oct 25, 2017, at 10:42 AM, Brendan Duddridge <bren...@gmail.com> wrote:The problem is that "propertiesAvailable" comes back with YES and then calling revision.properties results in a NULL value and I get the WARNING error message too.