Skip to content

Instantly share code, notes, and snippets.

@excieve
Created March 10, 2017 21:26
Show Gist options
  • Save excieve/4b94749652f8503e31422b103e5a6837 to your computer and use it in GitHub Desktop.
Save excieve/4b94749652f8503e31422b103e5a6837 to your computer and use it in GitHub Desktop.
fun({Doc}) ->
{Step0} = proplists:get_value(<<"step_0">>, Doc, {nil}),
{Step1} = proplists:get_value(<<"step_1">>, Doc, {nil}),
case proplists:get_value(<<"declarationType">>, Step0, nil) of
<<"1">> ->
Id = proplists:get_value(<<"_id">>, Doc),
Lastname = proplists:get_value(<<"lastname">>, Step1),
Firstname = proplists:get_value(<<"firstname">>, Step1),
Middlename = proplists:get_value(<<"middlename">>, Step1),
Result = {[
{<<"FIO">>, <<Lastname/binary, " ", Firstname/binary, " ", Middlename/binary>>},
{<<"workPost">>, proplists:get_value(<<"workPost">>, Step1, nil)}
]},
Emit(Id, Result);
_ -> nil
end
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment