Would anyone be willing to provide a full documentation example on how to write a couchdb design document?
I've never been able to find a proper documentation on that. I'm able to find a list of the available methods, but not how to write them in the design document. For example, the couchdb documentation in this page explains how to use a map function, but it doesn't explain that this function is implemented in the design document the following way:
{
"views": {
"someView": {
"map": "function(doc){ emit(doc.name, doc) }"
}
}
}
There are very sparse information on that in this page but it seems very incomplete to me. For example it doesn't even mention there can be "validate_doc_update" in the structure.
I think a good documentation example would be very useful in the couchdb doc itself in fact.
It could look like the following:
{
"_id": "_design/exampleDesignDocument",
"_rev": "1-11111111111111111111111111",
"views": {
"someView": {
"map": "function(doc){ emit(doc.name, doc) }",
...
}
},
"lists": {
"someList": "function(head, req){ send('<html>hello</html>') }"
}
...
}
This example would display usages of all design documents methods including (but not limited to if I forgot some): view (map, reduce functions...), show, list, update, filter, validate.