Regarding push-pull operation


I have created application using couchbase lite, i am trying to replicate data on server,
flow of code is like :

call replication pull
call replication push
(I have seperated two method i.e. push and pull)
(I have seen in many tutorials like push and pull are used at same time so i’m lil confused :stuck_out_tongue: )
so is this good practice?
please suggest…


Push and pull are used simultaneously because otherwise you’re only doing 1/2 the job of a full sync. By that I mean if you want a Couchbase Lite database fully synced with some other database, you must both push changes made in the CBL db, and pull changes made in the other db.

It’s very common to write apps that want full sync happening on an ongoing basis. In this case, you will see both a push and a pull set up to run continuously.

There are reasonable cases where you might want to sync only under specific conditions, or where you only want to push or pull data. The first start of an app is a good example. You might want to do a pull to initialize the database before a user starts changing anything. In that case, you would set up a one-shot pull replication.

Without knowing more about your particular use case, it’s hard to say whether what you’re doing makes sense.


Push and pull are asynchronous operations. When you call Replication.start, it begins replication in a background thread; the call returns immediately. That’s how both can be happening at once.