I have a sample app I have built to demo an internal application for our business with very little functionality. The goal is to have a set of master (or static) and transaction data that is accessible from all clients. In a real world scenario the master data would be changing often so we cannot package the master data in a prebuilt db as suggested in the tutorials. I understand how to filter this from the sync gateway, but for now I just want to pull all of the data as its very little (maybe 100 documents).
What I have so far:
Working swift4 application that can create a set of master data and can create transactions as needed fine.
Working sync gateway and server connected with client iOS devices.
My issue is if I open another device to demo the speed of couchbase in a meeting all of the master data is not downloading. I checked the sync gateway during the application and nothing seems to be syncing unless its a specific change to one of these and in that case my change listeners pick up the data fine. So my question, is how do I sync the data that doesn’t have changes and already exists in the bucket? The following is my sync gateway code and snippets of code setting up replication from the iOS app. When building my database manager class, on initialization I configure the DB, start the live query and try to print any of the data to the console.
Sync Gateway:
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
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
Thanks this all makes sense. Though I am not sure this is answering completely how I need to resolve my current issue. So I have a second device which from the above establishes a UUID to that DB on that device and the original connection to the sync gateway should be asking for all. However, this is not happening with my current code above.
Would the UUID generated also be relevant to the user account accessing the sync gateway? Currently I have only been testing with one user.
@househippo, the UUID stuff is irrelevant here, or rather Too Much Information. All you need to know, @mraby, is that any CBL database instance tracks its own replication state, as you’d expect.
If I understand correctly, the problem is that you can push documents to the server, but when you pull into an empty database you get no documents, unless a document is later changed on the other db? That’s unexpected. The initial pull should download all of the existing documents.
First off, are you on the latest developer build (20, I believe?)
Try turning on CBL logging in the Replicator domain. This will log a bunch of stuff, among which should be some indication of what docs are being downloaded. Upload that somewhere like a gist, then post a link to it here.
Sorry all some production issues took me away from my couchbase projects, thank you so much for the replies.
@jens you are correct in understanding my issue. I thought I updated it to DB 21, but I don’t see the build in any logging in xcode when I run the app with log level set to all. I have added the framework manually and if its helpful here is the plist in the framework package, but I don’t see the build version.
I did not have build 21. After installing I have some updates to make to the code as some functions were removed that I was testing with. I will respond later today if the new build resolves my issues and post the logs as requested if not.
Sorry for the delay. New years projects have caused some production issues with some of our applications. I just updated the code and the replication is working as expected with no changes to the sync gateway required. Something in DB20 was preventing the changes from being read in app. Thank you all for helping.