How do I download all data to client?

Each device and each time you install your application with CBL its creates a UUID internally.

So when CBL connects to SG. It will create a checkpoint ,using the above UUID, and check to see if that checkpoint is in SG.
If not It will ask for all the changes since=0&active_only=true (don’t include deleted documents) when SG was first created.
After its finish pulling all the data the app will update the checkpoint in Sync gateway to EX 1000.

So next time it pulls data from SG it will say since=1,000&active_only=false(include deleted documents) and get the changes and new documents since 1,000

MORE DETAIL on Replication : Replication Algorithm · couchbase/couchbase-lite-ios Wiki · GitHub

DELETES vs PURGE

PURGE - So if you purged a document(Completed Removed) from SG it will not sync(b/c it doesn’t exist).
DELETE - If you _deleted:true a document it will NOT remove the document , but it will mark it as deleted:true(i.e. a tombstone) so that CBL will be aware that document should no longer should be available on the device.

PRO TIP - The other side of the conversation.
Many times people might expriance slowness in downloading large data sets. To understand why you have to see what SG is doing via logs. Here is a forum post that talks about changed SG cache setting and found the performance it needed. Understanding in sync gateway logging - #4 by househippo

2 Likes