我使用Angular(js)和pouchdb作为本地db和couchbase作为远程数据库。 angularjs代码
.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);
});
};
我在复制到了无效的文档ID
时收到错误这是复制一切来证明这个概念。我的下一个问题是将复制过滤到数据,只过滤到本地生成的数据。