new_gist_file.erl
fun(Head, {Req}) ->
Send(<<"[">>),
Fun = fun({Row}, Virgula) ->
Send(Virgula),
case proplists:get_value(<<"doc">>, Row) of
{Doc} ->
Elocalitate = proplists:is_defined(<<"Siruta">>, Doc),
if
Elocalitate ->
Send(<<"[\"">>),
Send(proplists:get_value(<<"id">>, Row)),
Send(<<"\",\"">>),
Send(proplists:get_value(<<"Nume">>, Doc)),
Send(<<"\",\"">>),
Send(proplists:get_value(<<"Siruta">>, Doc)),
Send(<<"\",\"">>),
Send(proplists:get_value(<<"Județ">>, Doc)),
Send(<<"\"]">>),
{ok, <<",">>};
true ->
{ok,Virgula}
end;
_ ->
{ok, <<",">>}
end
end,
{ok, _} = FoldRows(Fun, <<"">>),
<<"]">>
end.