You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Ning Tan <ni...@gmail.com> on 2010/04/14 03:09:05 UTC
Re: Is there any way of adding a new member to an object in the map
function?
On Mon, Apr 12, 2010 at 10:45 PM, Cesar Delgado <be...@ymail.com> wrote:
> I'd love to just have a new JSON oabject as the value and no key.
>
> function(doc) {
> var hash = md5(doc.passwd) ;
> doc.insertmefunct("hash",hash) ;
> emit(null,doc) ;
> }
>
> would produce:
>
> {"name":"cesar", "passwd":"insecure","hash":"f166786326d565962e8523266c0e1d57"}
doc is just a plain old JavaScript object:
doc.hash = hash;
should do the trick. Of course, this is only a view output and is not
modifying the original document in the database.