Show and List Functions are used to transform single documents (show) and multiple documents e.g. from a view (list) into anything you want: JSON, HTML lists, SVG graphs…
So, what have I done? First you need to enable the Erlang view server. The “How to Enable Erlang Views” wiki page tells you what to do: Add a new section to your
local.ini or via Futon.
ad_id in that case.
1 2 3 4 5 6 7 8 9 10 11 12
And here is the Erlang version with the same functionality. I’m very new to Erlang so there might be (much) room for improvement :)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Although this might not be a very good example, I’ve learned some things. The Bindings available in the native Erlang views are defined in src/couchdb/couch_native_process.erl#299. Available are
Emit (for Views),
GetRow which are the counterparts to
FoldRows can be used as a helper to iterate over all rows in a list function.