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 <[email protected]> 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 [email protected] > > On Mar 25, 2013, at 12:46 PM, "Pearce, Martyn" <[email protected]> > wrote: > > > thanks > > > > -----Original Message----- > > From: Mark Hahn [mailto:[email protected]] > > 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 > > <[email protected]>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:[email protected]] > >> 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 > >> <[email protected] > >>> 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:[email protected]] > >>> 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.
