Skip to content

Instantly share code, notes, and snippets.

@andywenk
Created May 8, 2012 22:00
Show Gist options
  • Save andywenk/2639721 to your computer and use it in GitHub Desktop.
Save andywenk/2639721 to your computer and use it in GitHub Desktop.
CouchDB rewriting
in _design/simple
"rewrites": [
{
"from": "/all",
"to": "_list/html/all_database_types",
"method": "GET",
"query": {
"reduce": false
}
}
]
firing:
http://127.0.0.1:5984/map-reduce/_design/simple/_rewrite/all/
result:
{"error":"unknown_error","reason":"badarg"}
stack trace:
[error] [<0.26698.0>] Badarg error in HTTP request
[info] [<0.26698.0>] Stacktrace: [{erlang,iolist_to_binary,[false],[]},
{couch_httpd_rewrite,
'-maybe_encode_bindings/1-fun-0-',2,
[{file,"couch_httpd_rewrite.erl"},
{line,453}]},
{lists,foldl,3,
[{file,"lists.erl"},{line,1197}]},
{couch_httpd_rewrite,handle_rewrite_req,3,
[{file,"couch_httpd_rewrite.erl"},
{line,147}]},
{couch_httpd_db,do_db_req,2,
[{file,"couch_httpd_db.erl"},
{line,230}]},
{couch_httpd,handle_request_int,5,
[{file,"couch_httpd.erl"},{line,317}]},
{mochiweb_http,headers,5,
[{file,"mochiweb_http.erl"},{line,136}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,227}]}]
[error] [<0.26698.0>] Uncaught server error: badarg
[info] [<0.26698.0>] 127.0.0.1 - - GET /map-reduce/_design/simple/_rewrite/all/ 500
@andywenk
Copy link
Author

andywenk commented May 8, 2012

the solution:

"query": {
"reduce": "false"
}

only strings are allowed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment