Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove local_seq #4080

Closed
nolanlawson opened this issue Jul 26, 2015 · 4 comments
Closed

Remove local_seq #4080

nolanlawson opened this issue Jul 26, 2015 · 4 comments

Comments

@nolanlawson
Copy link
Member

Might as well get this in for 4.0.0.

nolanlawson added a commit that referenced this issue Jul 26, 2015
nolanlawson added a commit that referenced this issue Jul 26, 2015
nolanlawson added a commit that referenced this issue Jul 28, 2015
@nolanlawson
Copy link
Member Author

f0639ea

@sansato
Copy link

sansato commented Mar 15, 2019

The ?local_seq=true option is still active in couchdb, and I don't see how else to get the sequence number matching the current rev of a document. I'm tasked with providing a promise for a particular replication stream being up-to-date with regard to a particular doc@rev, which is easy if I can get its seq. Is there a recommended pouchdb alternative (that works with a remote db) that returns such seq?

https://docs.couchdb.org/en/2.3.1/api/document/common.html

@karlwestin
Copy link
Contributor

karlwestin commented Mar 15, 2019

This depends a lot about what you're trying to do, it's a bit tricky

Unfortunately PouchDB sequence numbers do not match CouchDB sequence numbers since 2.0, and if CouchDB runs in multi-node mode CouchDB sequence numbers might not match each other either.

What you can do is to store the result of your push replication (i assume this is about whether you uploaded all your changes to the server) in a local doc, then use that sequence to look for changes after that number

localDB.changes({ since: last_push_update_seq, doc_ids: 'myDocID' })
   .then(changes => {
      // if there's no changes to this doc since last sync, you're good
      return changes.results.length === 0
   })

If you are online, you can compare the revision on your local doc against the revision on the server.

Storing the last update seq of a replication is a bit involved and i'm sorry i can't provide that to support your project, but in general:

  • if you're replicating with live: false you get the last synced sequence from the promise
  • if you are doing live: true you'll have listen for the 'paused' event and call localDB.info() when that happens

@sansato
Copy link

sansato commented Mar 15, 2019

Thanks for this. It opens some options I hadn't seen. Especially appreciating the heads-up about server seq numbers when using a couchdb cluster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants