Is it possible to get the latest seq number of PouchDB?

血红的双手。 提交于 2019-12-25 00:43:15

问题


I am trying to cover for an issue where CouchDB is rolled back, causing PouchDB to be in the future. I want to find a way to detect this situation and force PouchDB to destroy and reload when this happens.

Is there a way to ask PouchDB for it's current pull seq number? I am not able to find any documentation at all on this. My google-foo is not strong enough.

So far my only thought is to watch the sync.on(change) feed, and record the seq number on every pull. Then on app reload, run this as ajax https:/server/db/_changes?descending=true&limit=1 and verify that the seq number this returns, is higher than the seq number I stored. If the stored seq is higher, then pouchdb.destroy(), purge _pouch_ from indexdb, and probably figure out how to delete websql versions for this release https://github.com/pouchdb/pouchdb/releases/tag/6.4.2.

Or is there a better way to solve situations where PouchDB ends up in the future ahead of CouchDB?


回答1:


The problem seems to be in the replication checkpoint documents. When you recover a database from the backup, probably, you are recovering also the checkpoint local documents.

You should remove all local docs, by finding them with the _local_docs endpoint and then removing form the recovered database.

Doing this, your PouchDB should try to send to CouchDB their docs syncing back PouchDB and CouchDB.



来源:https://stackoverflow.com/questions/49984794/is-it-possible-to-get-the-latest-seq-number-of-pouchdb

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!