Consider trying Photon (https://github.com/ermouth/couch-photon) for playing with Erlang views. It will look like this http://ermouth.com/dl/erlang_view.jpg
Your view – even with line breaks – works pretty fine when correctly serialized into .views.*.map string. ermouth вт, 30 июл. 2019 г. в 11:10, Shipra Choudhary <shipra.choudh...@dltlabs.io>: > *Hi,* > > I am trying to write a view in CouchDb by Erlang whatever the code I have > written in Design Document it is running successfully but I am not getting > the required result which I am expecting. That code is giving random result > of random doctype not for which I am asking. > > "_id": "_design/erl_views9", > > "_rev": "18-02fbdaca7ff5a7ef8aa0ec80a1b8f528", > > "language": "erlang", > > "views": { > > "getTemplates": { > > "map": "fun({Doc}) -> Id = couch_util:get_value(<<\"_id\">>, Doc), > Doc_type = couch_util:get_value(<<\"TEMPLATE\">>, Doc),Emit(Id, Doc_type) > end." > > } > > } > > } > > If I am using If in the code then It is giving error of Bad Query. > > ERROR: Error running query. Reason: ({badmatch,[<<"error">>, > {1,erl_parse,["syntax error before: ","'end'"]}, {1,erl_parse,["syntax > error before: ","'end'"]}]}) > [{couch_query_servers,'-start_doc_map/3-fun-0-',2, > [{file,"src/couch_query_servers.erl"},{line,61}]}, > {lists,foreach,2,[{file,"lists.erl"},{line,1337}]}, > {couch_query_servers,start_doc_map,3, > [{file,"src/couch_query_servers.erl"},{line,60}]}, > {couch_mrview_updater,start_query_server,1, > [{file,"src/couch_mrview_updater.erl"},{line,231}]}, > {couch_mrview_updater,map_docs,2, > [{file,"src/couch_mrview_updater.erl"},{line,184}]}] > > > What am I expecting ? > > By passing particular key in doc_type and should get all the views > according to key value which I will pass in the function. > > > > > > > *Shipra Chaudhary* > *Software Engineer* > > *+91 6390167803* > *shipra.choudh...@dltlabs.io <shipra.choudh...@dltlabs.io>* > > *Plot No. 5 **J V P Building,**4th Floor,**Madhapur,* > > > * Hyderabad, Telangana- 500081, India.* >