incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luke Bredeson <luke.brede...@gmail.com>
Subject Erlang view question
Date Sun, 20 Nov 2011 17:38:14 GMT
Hi,

I have an Erlang view that is outputting a list of integers instead of a
string.  I know Erlang treats strings as lists of integers, but I thought
CouchDB would take care of this for me.  I'm sure it's a basic error on my
part, so if anyone has any ideas of what I'm doing wrong, I'd appreciate
it!  Here's the relevant map function:

      fun({Doc}) ->
        case couch_util:get_value(<<"type">>, Doc) of
          <<"Crash">> ->
            Accdate = couch_util:get_value(<<"accdate">>, Doc),
            Year = string:substr(erlang:bitstring_to_list(Accdate), 7, 4),
            Emit([couch_util:get_value(<<"city">>, Doc), Year], 1);
          _ ->
            ok
        end
      end.

I get values like:  ["3425", [50, 48, 48, 56]], when I'm really looking for
values like this:  ["3425", "2008"].

Thanks,
Luke

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message