I am currently struggling a bit with CouchDB's difference between view and show functions. I am using CodeIgniter to query the CouchDB via curl. I have no attached templates in _design documents. Each template is loaded via CI's view method as plain HTML. With the help of Mustache.js I want to be able to make use of Mustache's pseudo-variables.
As I understood from the documentation, view results are always presented in key:value pairs.
Let's say I have the following result from http://127.0.0.1:5984/blog/_design/entries/_view/all
{"total_rows":2,"offset":0,"rows":[
{"key":"56a13b96ea3492ef8c7e554f67000952","value":{title:"First post"}},
{"key":"56a13b96ea3492ef8c7e554f670015a9","value":{title:"Second post"}}
]}
Following Mustache's methodology I would be able to do something like this:
{{#rows}}
<div class="entry">
<h1>{{#value}}{{title}}{{/value}}</h1>
</div>
{{/rows}}
This is acceptable but I would rather do something like this:
{{#entries}}
<div class="entry">
<h1>{{title}}</h1>
</div>
{{/entries}}
How am I able to do this? Is there something that needs to be altered in the view function or can this simply not be done through a view function? Do I need show functions here? If yes, what is the easiest way to create one? Questions, questions, questions...