Ok, I figured out how to sort by sequence number. I didn't see the 
kCBLBySequence option for that:

CBLQuery *docsQuery = [database createAllDocumentsQuery];

docsQuery.allDocsMode = kCBLIncludeDeleted | kCBLBySequence;

docsQuery.mapOnly = YES;

CBLQueryEnumerator *docsEnumerator = [docsQuery run: &error];


So the next challenge is how to query by sequence number. Can I specify the 
startKey and endKey and pass in the sequence number? I wouldn't think so 
because those are to query the view's key for a range of results. Not sure 
yet how to fetch all documents after a specific sequence number.

Thanks,

Brendan



On Monday, August 22, 2016 at 12:15:17 AM UTC-6, Brendan Duddridge wrote:
>
> Hi Jens,
>
> Run an all-docs query sorted by sequence starting just past the last 
>> sequence you synced
>>
>
> I know how to create an all-docs query, but how do I sort it by sequence 
> number starting just past the last sequence synced?
>
> Is there a way I can query for the last sequence synced? And does the 
> putExistingRevisionWithProperties function update that automatically? Or do 
> I need to keep track of that separately in a local document in the database?
>
> I know that I can query by startKey but can I query on the last synced 
> sequence to get all the changes in the database since I last synced? And 
> for sorting by sequence number, do I set the sortDescriptors on the query? 
> Doesn't that do the sorting in memory after querying the database? And can 
> I sort by sequence number in that case?
>
> If you have some code example that shows me how to query all documents to 
> get a list of changed documents since the last sync that would be super 
> helpful.
>
>
> Thanks,
>
> Brendan
>
> On Monday, August 8, 2016 at 12:11:52 PM UTC-6, Jens Alfke wrote:
>>
>>
>> > On Aug 8, 2016, at 10:12 AM, Brendan Duddridge <[email protected]> 
>> wrote: 
>> > 
>> > But many of my customers would prefer to use something like iCloud or 
>> Dropbox for syncing. In fact, I just released the new version of my app 
>> after a year in development switching over to Couchbase Lite and I've been 
>> roasted in the app reviews because I dropped support for iCloud and Dropbox 
>> syncing. 
>>
>> You can never please all the users… 
>>
>> > 
>> > But I was wondering what the viability of using that method would be to 
>> provide a file based sync solution? What I mean by that is I would take 
>> incremental snapshots of the changes made since the last time a sync 
>> operation occurred, then I would store the change file in iCloud Drive or 
>> Dropbox and then on the other device, read the changes file and process it 
>> using putExistingRevisionWithProperties. 
>>
>> Yeah, building some kind of “change archive” like this wouldn’t be hard. 
>> Run an all-docs query sorted by sequence starting just past the last 
>> sequence you synced, then for each document write its current revisions' 
>> JSON and all attachment bodies whose revpos is equal to the current 
>> revisions’ generation. 
>>
>> A Zip archive would be a convenient way to store this, where the internal 
>> filename is either the docID or “docID/attachmentname”. 
>>
>> But you’d have to write and upload a new snapshot every time you sync. A 
>> device coming online has to read each snapshot that’s newer than the latest 
>> one it’s read. So it’s not clear how you can ever delete old snapshots. 
>>
>> —Jens
>
>

-- 
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/1b200fcc-748b-47c7-a0f1-b6f244ba0843%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to