Skip to content

Instantly share code, notes, and snippets.

@javierg
Created December 7, 2013 16:01
Show Gist options
  • Save javierg/7844337 to your computer and use it in GitHub Desktop.
Save javierg/7844337 to your computer and use it in GitHub Desktop.
This is an Erlang couchdb view for getting all the documents that meet the "namespace/id" criteria, emiting the namespace as document type.
% Document design: {"_id": "namespace/edf42", ...}
fun({Doc}) ->
Id = proplists:get_value(<<"_id">>, Doc, null),
NameSpace = binary:bin_to_list(Id),
case re:split(NameSpace, "[/]") of
[_] -> null;
[Type, BaseId] -> Emit(Type, BaseId)
end
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment