On Wed, Jun 22, 2011 at 10:17, Jens Alfke <[email protected]> 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?

Youisright. But it would work. ;)

>
> 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.
>
> —Jens

Careful, this is not cheap (yet):
https://issues.apache.org/jira/browse/COUCHDB-941
(The workaround is be sure to specify ?limit=1 or some similarly
restrictive query)

Why do you need to know the difference and what defines "created" for you?
Would a document that replicated from elsewhere count as "created" or
only if it's the first revision?
What if revision 2-* replicates in?

Reply via email to