PouchDB 中最大实时复制数量

Giu*_*aci 6 pouchdb ionic-framework

我正在开发一个带有 PouchDB 的 Ionic 应用程序,需要将表与远程 CouchDB 服务器同步。在我的database.ts提供者的构造函数中,我有6个方法:

this.initialiseDB_Ord();
this.initialiseDB_IngProd();
this.initialiseDB_Ing();
this.initialiseDB_Prod();
this.initialiseDB_OrdProd();
this.initialiseDB_Ut();
Run Code Online (Sandbox Code Playgroud)

这些方法中的每一个都执行以下操作(我选择第一个作为示例):

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);
});
Run Code Online (Sandbox Code Playgroud)

然后我有一个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);
  });
}
Run Code Online (Sandbox Code Playgroud)

如果我最多有 5 个数据库,它就可以正常工作。添加第六个数据库时,它不会实时同步本地 pouchDB 和远程 couchDB,而是仅在应用程序首次打开时同步。

有人能帮我吗?

red*_*off 6

@lossleader 关于浏览器/WebView 中最大连接数的说法是正确的。在Quizster,我们也遇到同样的问题,因为 Quizster 必须同时同步多达 10 个 PouchDB 实例。这是使用Howler订阅一组数据库的更改来完成的。对这些数据库之一进行更改后,Quizster 会在 PouchDB 实例和 CouchDB 集群之间发出一次性(非实时)同步。

了解更多背景信息:Quizster 必须同步这么多 PouchDB 实例,如下所示:

  1. 这样做可以避免在数据库之间复制更多数据,从而降低共享数据的延迟
  2. Quizster 使用大量数据库视图来加速复制并保持较小的数据集大小。而且,每个视图都会有效地指向其自己的 PouchDB 实例。

我计划很快开源更多 Quizster 堆栈,并希望发布一些教程。