Benoit Chesneau wrote:

2009/6/18 Nils Breunese <[email protected]>:

Yes, being able to write show functions is nice, but you'll have to request
another URL if you want the document in a non-JSON format, which is not
really the REST way of doing business.

Of course you can just always request the show function URL, also for JSON
output, but AFAIK the output of show functions is not prerendered by CouchDB
(yet?), so performance-wise it might be better to go to the document-URL
itself directly if you want JSON. Are there any plans to (maybe optionally)
prerender the output of show functions? Maybe this is even possible for list
functions if heads, rows and tails are prerendered separately?

Something like this woudl allow you to follow REST principle :

function(doc, req) {
  return respondWith(req, {
    "html": return { body: "somehtml" },
    "json": return { "headers": "Content-Type: application/json", json: doc }
  }
}


But only for get for now.

Yeah, that is what I described and implemented. You'd need "json: return toJSON(doc);" though.

I don't think list views can be prerendered, as there are dynamic things like rowcounts that can't be prerendered AFAIK, but our application would benefit from prerendered show views for our documents.

Any idea what the overhead of serving JSON via toJSON(doc) in a content negotiation show function is over getting the JSON document directly?

Nils Breunese.

Reply via email to