couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stock, Ingemar" <Ingemar.St...@Philotech.de>
Subject Struggling with erlang
Date Mon, 07 Jan 2013 12:12:06 GMT
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


Mime
View raw message