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 2008/09/11 16:20:26 UTC
[Couchdb Wiki] Update of "Views" by MichaelHendricks
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.
The following page has been changed by MichaelHendricks:
http://wiki.apache.org/couchdb/Views
The comment on the change is:
briefly mention reduce functions
------------------------------------------------------------------------------
== Basics ==
+ === Map Functions ===
+
- Here is the simplest example of a view function:
+ Here is the simplest example of a map function:
{{{
function(doc) {
@@ -89, +91 @@
''This example output was reformatted for readability.''
+ === Reduce Functions ===
+
+ '''This section is only a stub. Please help by expanding it.'''
+
+ Here is an example of a reduce function:
+
+ {{{
+ function (keys, values, combine) {
+ return sum(values);
+ }
+ }}}
+
+ Reduce functions should return a single scalar value.
+
== Lookup Views ==
The second parameter of the ''emit()'' function can be ''NULL''. CouchDB then only stores the key in the view. If you use the document's ID here, you can use the view as a compact lookup mechanism and fetch the document's details, if needed, in subsequent requests.