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 2012/01/17 01:19:12 UTC
[Couchdb Wiki] Update of "Formatting_with_Show_and_List" by GeorgeSerbanut
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.
The "Formatting_with_Show_and_List" page has been changed by GeorgeSerbanut:
http://wiki.apache.org/couchdb/Formatting_with_Show_and_List?action=diff&rev1=30&rev2=31
Show and list functions are side effect free and idempotent. They can not make additional HTTP requests against CouchDB. Their purpose is to render JSON documents in other formats.
== Showing Documents ==
- [[http://guide.couchdb.org/draft/show.html|CouchDB Guide section]]
+ . [[http://guide.couchdb.org/draft/show.html|CouchDB Guide section]]
Show functions are stored in your design document, under the `shows` key. Here's an example set of show functions:
@@ -69, +69 @@
Since CouchDB 0.11.0 you can use the `send()` function as explained below in show functions as well.
== Listing Views with CouchDB 0.10 and later ==
- [[http://guide.couchdb.org/draft/transforming.html|CouchDB Guide section]]
+ . [[http://guide.couchdb.org/draft/transforming.html|CouchDB Guide section]]
List functions are stored under the `lists` key of a design document. Here's an example design doc with list functions, in addition to views:
@@ -77, +77 @@
{
"_id": "_design/examples",
"views" {
- "posts-by-date": "function(doc){ /*...*/ }",
+ "posts-by-date": {"map": "function(doc){ /*...*/ }"},
- "posts-by-tag": "function(doc){ /*...*/ }",
+ "posts-by-tag": {"map": "function(doc){ /*...*/ }"},
- "people-by-name": "function(doc) { /*...*/ }"
+ "people-by-name": {"map": "function(doc) { /*...*/ }"}
},
"lists": {
"index-posts": "function(head, req) { /*...*/ }",
@@ -185, +185 @@
start({"code": 302, "headers": {"Location": "/"}});
}
}}}
-
See [[Advanced_Shows_and_Lists_Throwing_Redirects]]
=== Specifying Content-Type Response Header ===