【发布时间】:2018-06-14 10:31:16
【问题描述】:
我正在使用 PouchDB 开发一个 Ionic 应用程序,该应用程序需要与远程 CouchDB 服务器同步表。 在我的 database.ts 提供程序的构造函数中,我有 6 个方法:
this.initialiseDB_Ord();
this.initialiseDB_IngProd();
this.initialiseDB_Ing();
this.initialiseDB_Prod();
this.initialiseDB_OrdProd();
this.initialiseDB_Ut();
这些方法中的每一个都执行以下操作(我选择第一个作为示例):
this._DB_Ord = new PouchDB('orders');
this._remoteDB_Ord = this.addressIP + '/orders';
this._syncOpts_Ord = { live : true,
retry : true,
continuous : true};
this._DB_Ord.sync(this._remoteDB_Ord, this._syncOpts_Ord)
.on('change',(info) => {
console.log('Handling syncing change');
console.dir(info);
}).on('paused',(info)=> {
console.log('Handling syncing pause');
console.dir(info);
}).on('active', (info) => {
console.log('Handling syncing resumption');
console.dir(info);
}).on('denied', (err) =>{
console.log('Handling syncing denied');
console.dir(err);
}).on('complete', (info) =>{
console.log('Handling syncing complete');
console.dir(info);
}).on('error', (err)=>{
console.log('Handling syncing error');
console.dir(err);
});
然后我有一个handleSyncing方法如下:
handleSyncingUt() {
this._DB_Ut.changes({
since : 'now',
live : true,
include_docs : true,
attachments : true
})
.on('change', (change) =>
{
console.log('Handling change');
console.dir(change);
})
.on('complete', (info) =>
{
console.log('Changes complete');
console.dir(info);
})
.on('error', (err) =>
{
console.log('Changes error');
console.log(err);
});
}
如果我最多有 5 个数据库,它就可以正常工作。 添加第六个数据库时,它不会实时同步本地 pouchDB 和远程 couchDB,而是仅在首次打开应用时同步。
有人可以帮我吗?
【问题讨论】:
-
当您尝试启动第 6 次实时复制时,具体会发生什么?您看到什么错误或其他失败迹象?
-
我没有看到任何错误。如果我在浏览器上刷新 Fauxton 页面,它不会更新为我发布的最后一项。使用 5 个 DB,它可以工作