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 1C5F6101E6 for ; Tue, 17 Sep 2013 14:50:08 +0000 (UTC) Received: (qmail 83508 invoked by uid 500); 17 Sep 2013 14:49:59 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 83441 invoked by uid 500); 17 Sep 2013 14:49:56 -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 83189 invoked by uid 99); 17 Sep 2013 14:49:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Sep 2013 14:49:54 +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 max@cloudant.com designates 209.85.217.173 as permitted sender) Received: from [209.85.217.173] (HELO mail-lb0-f173.google.com) (209.85.217.173) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Sep 2013 14:49:50 +0000 Received: by mail-lb0-f173.google.com with SMTP id o14so5410254lbi.4 for ; Tue, 17 Sep 2013 07:49:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=/b1QcjzlVFx87yzXxrm/N0QaMhOuSgpyW51vulsTPQI=; b=kQJdPEkwBiOmAE3nZCoekXN/oUbm5R/JzTG2qGp9QS1UxQr6dXLuRW0eSkoNyeEJSs jh0nqzIMjGZDlbge2Ttvah27HSZiMN/JkB8H34koXJ+W1rnLgo6dEZ4J5E48hI140uGx 7lgtivuZ3ijeP/X7vo1ckiwcicXXLbcGs12/AGstTCG1QB/3lNWDbbBcgd4YJfngEcYe uJzZw9Rz6cQscnCf8PNeHj5UkAb0DJAsAyjMuGGqqAjTwA4ubAi4UmvT85ByJDMfVss/ eyE18uOeGvDWMbnUTgQyX7O8t5lBckBIqGcGpEtRsVdAQpu2e5MMVZHm3Zdgk+FJCV+B zBpA== X-Gm-Message-State: ALoCoQlPqZWbpYKflJ0ETLVqj8UXSr5u8UKMg2O3D1wOMjUL1jeVnVU3G8Z725iXp44iSKdbty31 X-Received: by 10.112.167.3 with SMTP id zk3mr11221623lbb.23.1379429369152; Tue, 17 Sep 2013 07:49:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.142.232 with HTTP; Tue, 17 Sep 2013 07:49:09 -0700 (PDT) In-Reply-To: References: From: Max Thayer Date: Tue, 17 Sep 2013 10:49:09 -0400 Message-ID: Subject: Re: Change document in validate_doc_update To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=001a11c264a48a932b04e6956d3c X-Virus-Checked: Checked by ClamAV on apache.org --001a11c264a48a932b04e6956d3c Content-Type: text/plain; charset=ISO-8859-1 Hey Suraj! Will update handlersdo the trick? Best regards, Max On Tue, Sep 17, 2013 at 10:29 AM, Suraj Kumar wrote: > I'd like to add extra fields to the document being created, just like how > _user works. > > These I'd like to be able to compute using the inputs provided by the user, > in perhaps, something like a validate function. > > I tried doing the following, in many different variations, knowing well > that this is only wishful thinking... and as expected, it didn't work: > > function (newDoc, oldDoc, userCtx) { newDoc['newField'] = 10; return > newDoc; } > > But I'd very much like to do what the _user database does - where by > setting password, the document ends up getting different fields. How is it > achieved? How can end users like me achieve the same for my business logic > and altogether bypass the need to write middleware code? (I'm having to > write middle ware code just to transform one json hash into another because > my system is a pure API. CouchApps won't just do it (complex, > already-existent-clients will use the API)). > > Regards, > > -Suraj > > > -- > An Onion is the Onion skin and the Onion under the skin until the Onion > Skin without any Onion underneath. > > -- > _____________________________________________________________ > The information contained in this communication is intended solely for the > use of the individual or entity to whom it is addressed and others > authorized to receive it. It may contain confidential or legally privileged > information. If you are not the intended recipient you are hereby notified > that any disclosure, copying, distribution or taking any action in reliance > on the contents of this information is strictly prohibited and may be > unlawful. If you have received this communication in error, please notify > us immediately by responding to this email and then delete it from your > system. The firm is neither liable for the proper and complete transmission > of the information contained in this communication nor for any delay in its > receipt. > --001a11c264a48a932b04e6956d3c--