PouchDB/CouchDB Sequence Counter on Replicate

前端 未结 1 1129
别那么骄傲
别那么骄傲 2021-01-05 19:52

I am live syncing a freshly minted pouchdb (3.3.1) to an established (iris) couchdb.

The initial replication happens successfully (pause event fire

相关标签:
1条回答
  • 2021-01-05 20:38

    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.

    0 讨论(0)
提交回复
热议问题