Push without pulling out of the Couchbase Lite

I am collecting some analytic data on my client device that does not require any raw data from the server database.

Is it possible to start with an empty database, add some analysis papers, and then when I'm ready to use push replication to add those papers to my server's database using a sync gateway?

I will have an analytics feed, but I don't want to pull EVERYTHING from that feed into my client database as it doesn't care what is already there, it only wants to add to it.

I would have asked this question in the Couchbase forums, but it is currently not working.

+3


source to share


2 answers


Of course, push and pull replication are completely separate, since you are not creating a push replication, you are not getting any data from the sync gateway.



+1


source


Use the following API from CBLDatabase

to upload data to the server.

/** Creates a replication that will 'push' this database to a remote database at the given URL.
    This always creates a new replication, even if there is already one to the given URL.
    You must call -start on the replication to start it. */
- (CBLReplication*) createPushReplication: (NSURL*)url;

      

Here's an example of how you can set up push replication.



NSURL* url = [NSURL URLWithString: @"https://example.com/mydatabase/"];
CBLReplication *push = [database createPushReplication: url];
push.continuous = YES; // NO for One-shot replication
//After authenticating and adding progress observers here, call -start
[push start];

      

You can set up pull replication (if needed) in a similar way using -createPullReplication:

. Read more here: Replication .

0


source







All Articles