# HG changeset patch # User Atul Varma # Date 1240259830 25200 # Node ID 4450be5d1b2fa4e0068a79480d58491d353363de # Parent 8f0b180267828f50ea93887e508ff89acc21b7fa Added reduce() example to the tutorial. diff -r 8f0b18026782 -r 4450be5d1b2f tutorial.html --- a/tutorial.html Mon Apr 20 13:31:32 2009 -0700 +++ b/tutorial.html Mon Apr 20 13:37:10 2009 -0700 @@ -60,6 +60,7 @@ }, finished: function(result) { displayInElement(result, 'author-keyed-view'); + tryAnotherView(); } }); } @@ -70,6 +71,31 @@
+

We could also try creating another view that adds a +reduce() function to group together the blog post titles with +the authors:

+ +
+function tryAnotherView() { + blogDb.view({ + map: function(doc, emit) { + emit(doc.author, doc.title); + }, + reduce: function(keys, values) { + return values; + }, + finished: function(result) { + displayInElement(result, 'author-titles-view'); + } + }); +} +
+ +

The output is as follows:

+ +
+
+