8

What is the difference between a show and a list function and what is the purpose for them?

I'm studying CouchDB right now and reading bunch of different tutorials for CouchDB but this question never was explained carefully. (at least I didn't find it)

Kuepper
  • 992
  • 13
  • 39

1 Answers1

13

A _show function is meant to transform a single document, while a _list function is meant to transform the results of a view.

Both of them are meant to take the data within your document(s) and transform them into some other format. For example, you can render as HTML, XML or any other format you specify via the content-type header. By doing this on the database itself, you can reduce some of the work your application layer needs to perform.

Also, there are ways to use _list functions to do additional filtering and transformation to view results, allowing for a lot more flexibility than a typical view.

Dominic Barnes
  • 28,083
  • 8
  • 65
  • 90
  • That means that I use _list for rendering the complete html file from a moustache template (ul and beyond). Whereas _show is used to transform a single object/document (li and content)? – Kuepper Jun 18 '11 at 15:34
  • Correct, although you are not limited to HTML. :) – Dominic Barnes Jun 18 '11 at 15:41
  • 1
    +1. To me, show vs. list is not about complete HTML rendering or not. It is about, are you converting a *document* into HTML, or are you converting a *view* into HTML. Otherwise, they are very similar. – JasonSmith Jun 19 '11 at 01:20