incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kowsik <kow...@gmail.com>
Subject Re: How to identify new docs in the _changes feed?
Date Wed, 22 Jun 2011 18:08:54 GMT
On Wed, Jun 22, 2011 at 10:17 AM, Jens Alfke <jens@mooseyard.com> wrote:
> By watching the _changes feed I can detect when a document is deleted (via the “deleted”
key), but is there a way to tell when a new document is created? There doesn’t seem to be
a corresponding extra key in the notification in this case.
>
> I am tempted to look for a prefix of “1-“ in the revision, but I’m pretty sure
that this is an implementation detail and revision IDs should be treated as purely opaque
cookies, amiright?
>
> The cheapest alternative I can think of is to do a HEAD on the _all_docs view after I
get a new notification from _changes, and see if its ETag has changed.

I typically have created_at and updated_at (monkey patch couchrest's
save method, assuming you are using ruby) in all of my documents which
makes it easy to know this difference.

K.
---
http://blitz.io
http://twitter.com/pcapr
http://labs.mudynamics.com

Mime
View raw message