CouchDB, Custom Erlang Map Functions

Posted by David in couchdb
Monday, February 15th, 2010 at 15:49
Some of you know we are working with CouchDB quite intensively here at echolibre, and so I figured we might as well share a few of our notes, hickups, ideas, implementations, etc. So I decided to make a series of short post on CouchDB (>= 0.10.0) and I would like to start with writing your first CouchDB view in Erlang.

Obviously, you have to make sure that you enabled native Erlang views. Make sure to read on how to enabled your Erlang views on the CouchDB wiki

Once you are done, you can go into Futon and you should see “Erlang” in the list of available view languages:

Futon CouchDB
Futon CouchDB

Ok, let’s get into technicalities and the interesting stuff now, imagine you have a bunch of documents in your database and you want to get a list of documents that have a “name” and a “value” field. In javascript the view would be quite simple, it would look somewhat like: