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 F1CD0F772 for ; Tue, 26 Mar 2013 03:30:19 +0000 (UTC) Received: (qmail 36724 invoked by uid 500); 26 Mar 2013 03:30:18 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 36204 invoked by uid 500); 26 Mar 2013 03:30:13 -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 36177 invoked by uid 99); 26 Mar 2013 03:30:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Mar 2013 03:30:12 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [74.125.82.171] (HELO mail-we0-f171.google.com) (74.125.82.171) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Mar 2013 03:30:06 +0000 Received: by mail-we0-f171.google.com with SMTP id d46so3750211wer.2 for ; Mon, 25 Mar 2013 20:29:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-originating-ip:in-reply-to:references :from:date:message-id:subject:to:content-type:x-gm-message-state; bh=RGqBxvJaPDnefQID2V8WMIQtnmCa2xUnF6fJkAeQ7IQ=; b=IrPaSQL3Xn3ydZjbVnLXYZbcPt9kXRtVTg9W9xzI8Or7ATmo+rCAnMa6MA2JriFNp6 m5V+mCk/9u6Ya2n0U4BmuIFgMWG0aRrykYJTji1PtxiWL77n3B2p/l7dpKlG6JnOJWdq mxbgPcDAAyy2X5zHWoIcXVIIJQapMOFYHRK3iVGgUBvEqC7Qi5FAlyltveSfDXS/Zkd/ Y1xcbe/E56njpvrXvA40XnJehigP/AdVLglk7arJxOZWgWuAFQxoi+p6nZXrff1W4pPW zaG8LvJNPzMOyQWEwH0RTzWuHPtQ/HEkIOcZt7n3nRBMRolw2Eu7z2PV3AUXF5+oMuBy Pugg== X-Received: by 10.180.87.193 with SMTP id ba1mr475066wib.10.1364268586028; Mon, 25 Mar 2013 20:29:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.32.106 with HTTP; Mon, 25 Mar 2013 20:29:25 -0700 (PDT) X-Originating-IP: [68.5.117.177] In-Reply-To: <20130325214241.710d07d4@svilendobrev.com> References: <7BF0E6DD-9A71-49AB-9640-8962F828D5FE@yahoo.com> <1650166E173D354E9382181CA2DA9B0C0BE792DF08@GSCMEUP05EX.firmwide.corp.gs.com> <1650166E173D354E9382181CA2DA9B0C0BE792DFC1@GSCMEUP05EX.firmwide.corp.gs.com> <1650166E173D354E9382181CA2DA9B0C0BE792DFD5@GSCMEUP05EX.firmwide.corp.gs.com> <9903085A-564C-4E0B-B2CA-539EB9E1AE80@yahoo.com> <20130325214241.710d07d4@svilendobrev.com> From: Mark Hahn Date: Mon, 25 Mar 2013 20:29:25 -0700 Message-ID: Subject: Re: Google Summer of Code topics To: user Content-Type: multipart/alternative; boundary=f46d0444813172e65004d8cb884d X-Gm-Message-State: ALoCoQm13XMVC0pmmQMEPm5mybiHtsUgmz2VNrROm4QMlASVobTtO/D27Fmcf7eZBmFxKJyUuLLq X-Virus-Checked: Checked by ClamAV on apache.org --f46d0444813172e65004d8cb884d Content-Type: text/plain; charset=ISO-8859-1 Does anyone have any suggestions for where to put code examples? There doesn't seem to be any place in the wiki. On Mon, Mar 25, 2013 at 12:42 PM, svilen wrote: > how about putting these as coding snippets in the wiki? > digging mail archives may not be done by many. > these make the read-update cycle look less scary and more "atomic". > > svil > > > On Mon, 25 Mar 2013 13:44:17 -0400 > Jeff Charette wrote: > > > I do something similar. Here it is in case anyone wants to look at > > it from a slightly different code perspective. > > > > /* underscore and underscore string are not needed, just my > > preference */ var _ = require('underscore')._, > > _s = require('underscore-string'), > > globalKeys = ['_id', '_rev', 'template', 'type', 'permissions']; > > > > exports.edit = function (doc, req) { > > > > /* add values from request */ > > _.each(req.form, function(val, key) { > > if (globalKeys.indexOf(key) === -1) { > > try { > > doc[key].value = JSON.parse(req.form[key]); > > } > > catch (e) { > > if (typeof doc[key] !== 'undefined') { > > doc[key].value = > > req.form[key]; } > > } > > } > > }); > > > > return [doc, { > > code: 200, > > headers: { > > 'Content-Type': 'application/json' > > }, > > body: JSON.stringify('render to template or return success') > > }]; > > }; > > > > You simply post to '_update/edit/docid' with form content. > > > > Jeff Charette | Principal > > We Are Charette > > web / identity / packaging > > > > m 415.298.2707 > > w wearecharette.com > > e jeffrey@wearecharette.com > > > > On Mar 25, 2013, at 12:46 PM, "Pearce, Martyn" > > wrote: > > > > > thanks > > > > > > -----Original Message----- > > > From: Mark Hahn [mailto:mark@hahnca.com] > > > Sent: Monday, March 25, 2013 4:45 PM > > > To: user > > > Cc: CouchDB Developers > > > Subject: Re: Google Summer of Code topics > > > > > > Here is the code in a gist .. > > > https://gist.github.com/mark-hahn/5238514 > > > > > > > > > On Mon, Mar 25, 2013 at 9:00 AM, Pearce, Martyn > > > wrote: > > > > > >> Posting it here would be a great start. That would imply > > >> permission for interested parties to post it on an examples page, > > >> I think. > > >> > > >> Thanks, > > >> > > >> -----Original Message----- > > >> From: Mark Hahn [mailto:mark@hahnca.com] > > >> Sent: Monday, March 25, 2013 3:59 PM > > >> To: user > > >> Cc: CouchDB Developers > > >> Subject: Re: Google Summer of Code topics > > >> > > >> How would you suggest I publish it? I don't have a blog. I guess > > >> I could post it here for now. It's not very big. > > >> > > >> > > >> On Mon, Mar 25, 2013 at 2:19 AM, Pearce, Martyn > > >> > >>> wrote: > > >> > > >>> It would be a great published example/howto if you were willing to > > >> publish > > >>> your code for that. > > >>> > > >>> -----Original Message----- > > >>> From: Mark Hahn [mailto:mark@hahnca.com] > > >>> Sent: Friday, March 22, 2013 6:14 PM > > >>> To: user > > >>> Cc: CouchDB Developers > > >>> Subject: Re: Google Summer of Code topics > > >>> > > >>>> Implement partial reads and updates of documents, > > >>> > > >>> In case anyone didn't know, you can do partial updates right now > > >>> with an update handler. I have been using one for some time that > > >>> allows the app > > >> to > > >>> modify any part of a doc with a single http request. It even > > >>> allows one > > >> to > > >>> modify an attribute nested inside objects. I've ended up using > > >>> only this for all updates. > --f46d0444813172e65004d8cb884d--