Database / CouchDB Interview Questions
What are CouchDB show functions and when were they deprecated?
Show functions are server-side JavaScript functions stored in a design document under the shows key. They transform a single document into any output format (HTML, XML, plain text) directly from CouchDB, without requiring a separate application server. When a client calls GET /db/_design/ddoc/_show/func_name/doc_id, CouchDB fetches the document, passes it to the show function, and returns the function's output as the HTTP response.
// In _design/render:
{
"shows": {
"as_html": "function(doc, req) {
if (!doc) { return { code: 404, body: 'Not found' }; }
return {
headers: { 'Content-Type': 'text/html' },
body: '' + doc.name + '
' + doc.description + '
'
};
}"
}
}
GET /mydb/_design/render/_show/as_html/product:001
Show functions were primarily used in CouchApps — self-contained web applications where HTML pages, CSS, JavaScript, and data were all served from a single CouchDB database. The appeal was zero-infrastructure: the database was the entire application stack. Show functions rendered individual documents as HTML pages; list functions (Q20) rendered view query results.
Deprecation: Show functions were officially deprecated in CouchDB 3.0 (2021) along with list functions and the legacy JavaScript-based rewrites system. They are disabled by default in CouchDB 3.x and will be removed in a future major version. The recommended approach is to handle document rendering in your application layer — any web framework can fetch a document via the REST API and render it. The JavaScript query server overhead, security isolation challenges, and limited debugging tooling made CouchApps impractical at scale.
More Related questions...