incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Zachary Zolton <zachary.zol...@gmail.com>
Subject Re: How to add IP address field to documents
Date Thu, 07 Jun 2012 14:38:57 GMT
Hi Pulkit,

You cannot modify documents in the validate_doc_update function--their
purpose is solely to check whether a document is valid. However you could
use an _update handler:

http://wiki.apache.org/couchdb/Document_Update_Handlers

Note the second parameter to that function is the request object, from
which you should be able to get the client's IP address.


Cheers,

Zach

On Thu, Jun 7, 2012 at 9:25 AM, Pulkit Singhal <pulkitsinghal@gmail.com>wrote:

> I would like to add an additional field to incoming documents in the
> validate_doc_field method. This field should store client info like the IP
> address. I hope that folks reading this thread find this to be same as
> adding a created_at or last_modified timestamps. And ofcourse the minor
> difference is that timestamps can be generated but for something like
> client ip address, it would have to be picked-up/passed-in from somewhere.
>
> I'm using CouchDB 1.2.0 and I'm used to the following method signature:
> function (new_doc, old_doc, userCtx) {...}
>
> But while Google~ing I have found two threads that hint at the existence of
> a different validation signature:
>  1.
>
> http://grokbase.com/t/couchdb/user/094xjv2zaz/validate-doc-update-modifying-doc
>  2. https://issues.apache.org/jira/browse/COUCHDB-1287
>
> Does this new signature actually exist in 1.2.0 or not?
> function (new_doc, old_doc, userCtx, http_headers) {...}
>
> Overall are there any suggestion on how to add an IP address field to
> documents on the fly?
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message