1

I am using pouchDB in an angular App to store local data, and also using crypto-pouch 3.1.3 plugin to encrypt local data in IndexedDB.

Here is my code :

PouchDB = require('pouchdb').default;
  Crypto = require ('crypto-pouch');
  Upsert = require ('pouchdb-upsert');

  pouch: any;
  remoteDB: any;

  constructor() {

    this.PouchDB.plugin(this.Crypto);
    this.PouchDB.plugin(this.Upsert);
    this.pouch = this.PouchDB('localDB', { auto_compaction: true })

    this.pouch.crypto('password')


    this.remoteDB = new this.PouchDB(`https://somesite.com/p/remotedb/`)

    this.pouch.sync(this.remoteDB).on('error', function (err) {

          console.log('couch sync error', err);
          
         });;

  }

The data in browser IndexedDB has been encrypted and the replication to remote CouchDB is also happening.

But every time i make an update to local data, after the update has been synced with remote db, there is a conflict in remote CouchDB. conflict happens in _rev field, it is very confusing

If i remove the crypto code

this.pouch.crypto('password')

everything back to normal, the update could be synced and no conflict. Except the local data is displayed in plaintext in IndexedDB.

I assume it could be a problem with crypto-pouch plugin, so i went to its github issues list, but no such issues posted.

Anyone know what is problem is, and how to solve it? Thanks~

Wayne Wei
  • 2,907
  • 2
  • 13
  • 19
  • It doesn't sound like there's a problem at all. It sounds like you are seeing the expected behavior when both instances perform an update, then sync. Maybe [this](https://stackoverflow.com/a/38919039/13860) can help clarify for you? Or [this](https://guide.couchdb.org/draft/conflicts.html)? – Jonathan Hall Feb 16 '21 at 07:03
  • Only local pouchDB was updated, not the remote CouchDB, it is weird conflict comes from nowhere. – Wayne Wei Feb 16 '21 at 14:14

0 Answers0