incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ning Tan <ning...@gmail.com>
Subject Re: Is there any way of adding a new member to an object in the map function?
Date Wed, 14 Apr 2010 01:09:05 GMT
On Mon, Apr 12, 2010 at 10:45 PM, Cesar Delgado <beettlle@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.

Mime
View raw message