You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Mike Keen <mk...@visiture.com> on 2010/06/03 19:40:18 UTC
Erlang Doc structure
I've been playing with Erlang views on and off in CouchDB, and find the information on the internal Erlang structure of Docs lacking. Is there somewhere I can read up on this? I had initially assumed that a Doc was a list of tuples, but I am starting to suspect that I am wrong.
Mike
Re: Erlang Doc structure
Posted by J Chris Anderson <jc...@gmail.com>.
On Jun 3, 2010, at 2:01 PM, Mike Keen wrote:
> In the same vein, how is a Value item within a reduce function represented in Erlang?
>
I don't know off the top of my head, but there is the ability to Log to the couch.log file from within an Erlang view.
For reference you might see: http://svn.apache.org/repos/asf/couchdb/trunk/share/www/script/test/erlang_views.js from the test suite.
Chris
> On Jun 3, 2010, at 3:26 PM, J Chris Anderson wrote:
>
>>
>> On Jun 3, 2010, at 10:40 AM, Mike Keen wrote:
>>
>>> I've been playing with Erlang views on and off in CouchDB, and find the information on the internal Erlang structure of Docs lacking. Is there somewhere I can read up on this? I had initially assumed that a Doc was a list of tuples, but I am starting to suspect that I am wrong.
>>>
>>
>> It's an erlang proplist, wrapped in a single tuple, so:
>>
>> {[{<<"key">>, value()}, {<<"other-key">>, value()}]}
>>
>> Where value() is any valid eJSON.
>>
>> So you can do eg:
>>
>> {Props} = Doc,
>> V1 = couch_util:get_value(<<"key">>, Props)
>>
>>> Mike
>>
>
Re: Erlang Doc structure
Posted by Mike Keen <mk...@visiture.com>.
In the same vein, how is a Value item within a reduce function represented in Erlang?
On Jun 3, 2010, at 3:26 PM, J Chris Anderson wrote:
>
> On Jun 3, 2010, at 10:40 AM, Mike Keen wrote:
>
>> I've been playing with Erlang views on and off in CouchDB, and find the information on the internal Erlang structure of Docs lacking. Is there somewhere I can read up on this? I had initially assumed that a Doc was a list of tuples, but I am starting to suspect that I am wrong.
>>
>
> It's an erlang proplist, wrapped in a single tuple, so:
>
> {[{<<"key">>, value()}, {<<"other-key">>, value()}]}
>
> Where value() is any valid eJSON.
>
> So you can do eg:
>
> {Props} = Doc,
> V1 = couch_util:get_value(<<"key">>, Props)
>
>> Mike
>
Re: Erlang Doc structure
Posted by Mike Keen <mk...@visiture.com>.
Thanks very much. That was very helpful!
Mike
On Jun 3, 2010, at 3:26 PM, J Chris Anderson wrote:
>
> On Jun 3, 2010, at 10:40 AM, Mike Keen wrote:
>
>> I've been playing with Erlang views on and off in CouchDB, and find the information on the internal Erlang structure of Docs lacking. Is there somewhere I can read up on this? I had initially assumed that a Doc was a list of tuples, but I am starting to suspect that I am wrong.
>>
>
> It's an erlang proplist, wrapped in a single tuple, so:
>
> {[{<<"key">>, value()}, {<<"other-key">>, value()}]}
>
> Where value() is any valid eJSON.
>
> So you can do eg:
>
> {Props} = Doc,
> V1 = couch_util:get_value(<<"key">>, Props)
>
>> Mike
>
Re: Erlang Doc structure
Posted by J Chris Anderson <jc...@gmail.com>.
On Jun 3, 2010, at 10:40 AM, Mike Keen wrote:
> I've been playing with Erlang views on and off in CouchDB, and find the information on the internal Erlang structure of Docs lacking. Is there somewhere I can read up on this? I had initially assumed that a Doc was a list of tuples, but I am starting to suspect that I am wrong.
>
It's an erlang proplist, wrapped in a single tuple, so:
{[{<<"key">>, value()}, {<<"other-key">>, value()}]}
Where value() is any valid eJSON.
So you can do eg:
{Props} = Doc,
V1 = couch_util:get_value(<<"key">>, Props)
> Mike