Felipe Taiarol
Felipe Taiarol

Reputation: 175

CouchDB - Get DB's update_seq based on document

I want to get all documents inside a CouchDB database and then listen to changes on that database. I could:

1- Get the docs using the _all_docs view. /db/_all_docs
2- Get the current db update_seq. /db .
3- listen to the changes in the database. /db/_changes?since=update_seq

But what if one or more documents are created right after I query the _all_docs view and before I get the update_seq? If that happens when I listen to the changes which happened after the update_seq I'll never receive those documents.

Is there a way to know what was the DB's update_seq when a given document had a given revision? With that, I could be 100% sure I'll never miss a document.

Upvotes: 1

Views: 234

Answers (1)

Dominic Barnes
Dominic Barnes

Reputation: 28429

Add update_seq=true to your request for _all_docs, you'll get the update_seq for the database at that time. (this avoids the race condition you are afraid of)

Upvotes: 2

Related Questions