Created
December 7, 2013 16:01
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% 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