Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CouchDB Last Seq Changes Feed

I think I'm going about something wrong here, maybe someone can clarify. I have an app that long polls CouchDB (via nodejs) for which it uses the changes feed. When my app makes it's first poll of the changes feed it doesn't know what the last_seq is so I've just been starting by polling with since=0, getting the last_seq and then polling again with since=last_seq.

However, I've run into a problem. Since my database has had several more documents added to it , the changes list is getting awfully long and when I request changes with since=0, the response appears to be getting cut off and I don't get the last_seq in the response. Hence I can't make a subsequent request without that last_seq.

Is there a way to get the last_seq without getting AAAAALLLL the changes from the beginning of time? Is there some way to truncate the changes feed every so often?

like image 440
skinneejoe Avatar asked Feb 14 '23 08:02

skinneejoe


1 Answers

Bah, nevermind. As usual I find my answer right after I post!

GET /dbname/_changes?descending=true&limit=1

From this post: How to get last created document in couchdb?

like image 98
skinneejoe Avatar answered Mar 03 '23 04:03

skinneejoe