Morgan Hayes
Morgan Hayes

Reputation: 383

how to replicate to and replicate from to remote databases, pouchdb to couchbase

I am using Angular(js) and pouchdb as local db and couchbase as remote database. angularjs code

.run(function ($pouchDB) {
    $pouchDB.setDatabase("local");
    $pouchDB.replicateFrom("http://couchbaseServer/office");
    $pouchDB.replicateTo("http://couchbaseServer/mobile");
})



 //pouchDB service code
         this.replicateTo = function(remoteDB) {
            database.replicate.to(remoteDB).on('complete', function () {
          // yay, we're done!
          alert("replicationTo done");
            }).on('error', function (err) {
              // boo, something went wrong!
              alert("data was not replicated to server, error - " + err);
            });
        };

        this.replicateFrom = function(remoteDB) {
            database.replicate.from(remoteDB).on('complete', function () {
          // yay, we're done!
          alert("replicationFrom done");
            }).on('error', function (err) {
              // boo, something went wrong!
              alert("data was not replicated from server, error - " + err);
            });
        };

i get an error on the replicate to, invalid doc id

this is replicating everything to prove the concept. My next question will be to filter the replicate to data to only the data generated locally.

Upvotes: 0

Views: 244

Answers (1)

Roi Katz
Roi Katz

Reputation: 575

In order to replicate data from PouchDB or CouchbaseLite for that matter you would need a synchronizing service which called "Sync Gateway".

SyncGateway implements the CouchDB replication interface and enables the replication.

more info can be found here and here

Upvotes: 1

Related Questions