PouchDB/CouchDB Sequence Counter on Replicate

拟墨画扇 提交于 2019-11-30 22:28:48

You can't really compare the seqs across two databases. However, you can do a db.info() on the remote database, grab the update_seq, and then compare that to the last_seq that is given to you in the on('change') event during replication. This will tell you how much progress you've made.

If you would like to see an example of this, the NPM Browser does exactly this, to show the percent counter at the top. (It uses pouchdb-load as well, but the principle is the same, since the seqs are reported there as well.) The code is open-source, so feel free to check out how it works. :)

Edit: as pointed out in a comment, if you are using sync rather than replicate, you need to check the direction parameter when reading last_seq. Also for Cloudant, you will need to split the string on - to get the integer seq.

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