I am working on an Ionic app with PouchDB that needs to sync tables with remote CouchDB server. In the constructor of my database.ts provider I have 6 methods:
this.initialiseDB_Ord();
this.initialiseDB_IngProd();
this.initialiseDB_Ing();
this.initialiseDB_Prod();
this.initialiseDB_OrdProd();
this.initialiseDB_Ut();
Each of these methods does the following (I pick the first one as example):
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);
});
then I have a handleSyncing method as follows:
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);
});
}
If I have at maximum 5 Databases it works fine. When the sixth DB is added it doesn't synchronize local pouchDB and remote couchDB in real time but only when the app is first opened.
Can someone help me?