Hey all,
can somebody help me to translate this filter function into Erlang, pls?
function(doc){
if(doc.type === "tile"){
return doc.key.length <= 8;
}else{
return true;
}
}
My first attempt was this, but I don't know how to do the "key.length <=
8" check and I'm not sure if this works at all:
fun({Doc}) ->
case {proplists:get_value(<<"type">>, Doc),
proplists:get_value(<<"key">>, Doc)} of
{undefined, _} ->
true;
{_, undefined} ->
true;
{Type, Key} ->
case {Type} of
{<<"tile">>} ->
true;
_ ->
false;
end;
_ ->
true;
end
end.
Thank you,
Ingemar