我想將最後一個修訂版本從couchDB複製到pouchDB,但是它將所有的轉換都轉移到了doc中。初始例如:如何將有用的數據從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轉換爲25Kb的1個文檔。考慮通過2g/3g連接傳輸的25kb x 603無用數據,並幫助我僅轉發有用的數據。
OBS:Fauxton緊湊&清潔是這個過程之前使用
您是否對PouchDB進行了與CouchDB同步的更改?或者所有更改都是在CouchDB中發起的,並且PouchDB的副本是隻讀的? – Flimzy
雙方都有變化,大部分變化都來自CouchDB –
在這種情況下,額外的轉速不是無用的數據;他們用於解決衝突。 – Flimzy