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 A00F4FEF9 for ; Mon, 25 Mar 2013 19:43:11 +0000 (UTC) Received: (qmail 66021 invoked by uid 500); 25 Mar 2013 19:43:10 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 65952 invoked by uid 500); 25 Mar 2013 19:43:09 -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 65944 invoked by uid 99); 25 Mar 2013 19:43:09 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Mar 2013 19:43:09 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [91.195.24.3] (HELO mail.open.bg) (91.195.24.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Mar 2013 19:43:03 +0000 Received: from [78.83.22.128] (port=50164 helo=localhost.localdomain) by mail.open.bg with esmtpsa (Cipher SSL3.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) id 1UKDI2-0001uD-FV by authid with login for ; Mon, 25 Mar 2013 21:42:42 +0200 Date: Mon, 25 Mar 2013 21:42:41 +0200 From: svilen To: user@couchdb.apache.org Subject: Re: Google Summer of Code topics Message-ID: <20130325214241.710d07d4@svilendobrev.com> In-Reply-To: <9903085A-564C-4E0B-B2CA-539EB9E1AE80@yahoo.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> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.16; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org 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.