couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kowsik <>
Subject Help with Erlang views
Date Wed, 05 Oct 2011 04:32:13 GMT
Was chatting with @jchris about erlang views and would love to get
some help on this. On we are in the process of investigating,
experimenting with Erlang views. Purely from an operational
perspective, we are not trying to become Erlang hackers. Just need to
know enough to be dangerous and make our CouchDB clusters fly and
scale out. :)

We are already using the built-in reduce functions and I as looked
through all of our design views, they mostly fall into the following
two buckets. I'm suspecting most other users' map functions fall into
this category.

function(doc) {
    if (doc.type === "foo" and {
        emit(Date.parse(doc.created_at), null);

@jchris pointed me to this but
would be awesome to see this part of utils:date_parse or date:parse as
a built-in function that can handle both strftime("%Y/%m/%d %H:%M:%S
+0000") as well as iso8601. This is a fairly common use case for us.

Next one is this:

function(doc) {
    if (doc.type === "foo" && {
        for (i in {
            if (doc.hasOwnProperty(i)) {
                emit([i], null);

Pretty much everything we have falls into using Date.parse or
iterating over an array/object to emit a bunch of KVs. Can someone
help translate this to Erlang please? I have googled around and seen a
few examples. The latter has some online examples using list:foreach,
but Date.parse didn't seem to have any.

Thanks and much appreciated,


View raw message