如何解决使用crypto-pouch插件时,PouchDB与CouchDB的同步与每次更新发生冲突
我在 angular App 中使用 pouchDB 来存储本地数据,并使用 crypto-pouch 3.1.3 插件加密 IndexedDB 中的本地数据。
这是我的代码:
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);
});;
}
浏览器 IndexedDB 中的数据已经加密,并且正在复制到远程 CouchDB。
但是每次我对本地数据进行更新时,更新已与远程数据库同步后,远程CouchDB 会发生冲突。
如果我删除加密代码
this.pouch.crypto('password')
一切恢复正常,更新可以同步,没有冲突。除了本地数据在IndexedDB中以明文显示。
我认为这可能是 crypto-pouch
插件的问题,所以我去了它的 github 问题列表,但没有发布此类问题。
有谁知道问题是什么,如何解决?谢谢~
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。