我正在尝试仅将最新版本从couchDB复制到pouchDB,但它是所有转速的转移文档。最初的例子:
var replicationOptions = {
doc_ids: null
};
this.$get = function (pouchDB, arrayUtils, $rootScope, modelUtils,appConfig) {
function initDB() {
userLocalDB = pouchDB("mobile_users", {
revs_limit: 1,
auto_compaction: true,
adapter: 'cordova-sqlite',
iosDatabaseLocation: 'Library',
androidDatabaseImplementation: 2
});
userRemoteDB = pouchDB(appConfig.couchDBServerUrl+"mobile_users", {skipSetup: true});
userRemoteDB.login("mobile", "fakepass");
}...
复制代码:
function startReplication(username) {
replicationOptions.doc_ids = [_prefixId + username];
console.log("replicationOptions", replicationOptions)
return userRemoteDB.replicate.to(userLocalDB, replicationOptions).$promise
.then(null, null, function (progress) {
console.log('user replication status', progress);
})
.then(function (result) {
console.log('user replication resolved with', result);
return true
})
.catch(function (reason) {
console.log('user replication exception', reason);
return startReplication(username);
})
}
console.log中的进度结果('用户复制状态',进度);
user replication status Object {change: Object}
change: Object
doc_write_failures: 0
docs: Array(604)
docs_read: 604
docs_written: 604
errors: Array(0)
last_seq: 452349
ok: true
start_time: "2017-07-07T18:37:34.353Z"
我很长时间都在寻找答案,但任何解决方案都是有效的。我不想从couchDB 604转换只有1个25Kb的doc。考虑通过2g / 3g连接传输的25 kb x 603无用数据,并帮助我仅传输有用的数据。
OBS:Fauxton Compact&在此过程之前使用了清洁