You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by Apache Wiki <wi...@apache.org> on 2010/10/04 05:39:52 UTC

[Couchdb Wiki] Update of "ApplicationSchema" by AndrewCooper

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.

The "ApplicationSchema" page has been changed by AndrewCooper.
The comment on this change is: References to "map" changed to "emit".
http://wiki.apache.org/couchdb/ApplicationSchema?action=diff&rev1=3&rev2=4

--------------------------------------------------

     "to_docs": "
        function(doc) {
          for( var i=0; i < doc.tags.length; i++) {
-           map(doc.tags[i], null);
+           emit(doc.tags[i], null);
          }
        }"
  }
@@ -105, +105 @@

  Say we're returning a lot of records here and want to reduce them by including the title (or if no title exists, the name) attribute of the thing that was tagged along with the results. Change the following line in the ''to_docs'' query above:
  
  {{{
- // map(doc.tags[i], null);
+ // emit(doc.tags[i], null);
  // becomes
- map(doc.tags[i], doc.title || doc.name);
+ emit(doc.tags[i], doc.title || doc.name);
  }}}
  
  Optionally, this view could be named to_docs_with_title so as to be available only if the extra data is desired.