Search code examples
iosswiftcouchdbcouchbase-litecouchbase-sync-gateway

in Couchbase, How to know whether all documents are synced or not.?


For Example, I have pull replication running, which is syncing documents of user login, but whenever user entering the username and logging in, the document of the particular user is not yet synced and it is showing no user found. So how to overcome this. Please help me out.

Thanks in advance!


Solution

  • To find out whether all the documents are synced or not one need to start the sync in one shot mode.

    In this continuous is set to false for pull replication. Push is always in continuous mode. So when the sync is started in one shot then when the replication status changes to Stopped then it means either the sync have finished or there is an error while syncing data.

    In case of an error haserror() function can be used to find out if the error is there or not. If there is an error then one need to restart one shot replication else the replication can be put in continuous mode and app can be used. Do note only one shot will have a status as Stopped

    following is the link where it is stated :- https://developer.couchbase.com/documentation/mobile/1.4/guides/couchbase-lite/native-api/replication/index.html