Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6F881C917 for ; Thu, 7 Jun 2012 14:39:57 +0000 (UTC) Received: (qmail 48900 invoked by uid 500); 7 Jun 2012 14:39:54 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 48831 invoked by uid 500); 7 Jun 2012 14:39:54 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 48689 invoked by uid 99); 7 Jun 2012 14:39:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Jun 2012 14:39:53 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of zachary.zolton@gmail.com designates 209.85.210.52 as permitted sender) Received: from [209.85.210.52] (HELO mail-pz0-f52.google.com) (209.85.210.52) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Jun 2012 14:39:48 +0000 Received: by dano14 with SMTP id o14so1029292dan.11 for ; Thu, 07 Jun 2012 07:39:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=b6bwAjIPgs6ydNgtZtzEyZ+BJ2MBeveMpySPkcCyY9I=; b=NuZR0Epp9PWv+iXJwyl/a+GGYbCZqgCZugP+AosfEc422/3lbz5r4zPt/+3oulGiqn AIMdyyaGcR2dGMpWunsBY/ehqDhnamc+FdBZC3Z2E8x8OkCg4DSW3OC0jtHtVT94fos4 +fs5oAY/QIb9rhL7u/U3GjX402S8Y21bcbFvzwOBU22fRoWJXvNZb9aczix/tKDOH+EP 9ox48qIhj0qH+CtWzQZOBXLXymVtAIL9iDpnXUwmQMDmwrVjGoeC3hkBrAz4gEG76hqq wJTvL+5ptaB0AanVtGrKGIDCjZmCHGuFk60RTE6JRw9CB6wyzej1EZFvQJ395/hMC2TE 8B8w== Received: by 10.68.225.135 with SMTP id rk7mr4985864pbc.38.1339079968168; Thu, 07 Jun 2012 07:39:28 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.222.36 with HTTP; Thu, 7 Jun 2012 07:38:57 -0700 (PDT) In-Reply-To: References: From: Zachary Zolton Date: Thu, 7 Jun 2012 09:38:57 -0500 Message-ID: Subject: Re: How to add IP address field to documents To: user@couchdb.apache.org Cc: couchdb-user@apache.org Content-Type: multipart/alternative; boundary=047d7b2ee0b7d419c804c1e2d95d X-Virus-Checked: Checked by ClamAV on apache.org --047d7b2ee0b7d419c804c1e2d95d Content-Type: text/plain; charset=ISO-8859-1 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 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? > --047d7b2ee0b7d419c804c1e2d95d--