Emit Tuples From Erlang Views In CouchDB

前端 未结 3 1999
一个人的身影
一个人的身影 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:37

    For test_suite_reports bd, that has tests field:

    [
       {
           "name": "basics",
           "status": "success",
           "duration": 21795
       },
       {
           "name": "all_docs",
           "status": "success",
           "duration": 385
       } ...
    

    I have wrote this to get name and status:

    fun({Doc}) ->
      Name = fun(L) ->  proplists:get_value(<<"name">>, L, null) end,
      Status = fun(L) -> proplists:get_value(<<"status">>, L, null) end,
      Tests = proplists:get_value(<<"tests">>, Doc, null),
      lists:foreach(fun({L}) -> Emit(Name(L), Status(L)) end, Tests)
    end.
    

提交回复
热议问题