Emit Tuples From Erlang Views In CouchDB

前端 未结 3 2025
一个人的身影
一个人的身影 2020-12-31 11:40

CouchDB, version 0.10.0, using native erlang views.

I have a simple document of the form:

{
   \"_id\": \"user-1\",
   \"_rev\": \"1-9ccf63b66b62d15d         


        
3条回答
  •  灰色年华
    2020-12-31 12:23

    The JSON object {"foo":"bar","baz":1} is {[{<<"foo">>,<<"bar">>},{<<"baz">>,1}]}

    In Erlang lingua it is a proplist wrapped in a tuple.

    It's not pretty, but very efficient :)

    To get a feel for it you can play with the JSON lib that ships with CouchDB:

    1. Start CouchDB with the -i (interactive) flag
    2. On the resulting erlang shell, type: couch_util:json_decode(<<"{\"foo\":\"bar\"}">>).
    3. Profit

    // in later versions of CouchDB, this is ejson:decode()

提交回复
热议问题