Support queries endpoints#1222
Conversation
7308961 to
01448da
Compare
01448da to
c0802dc
Compare
|
Could somebody please help review this PR? Thanks |
eiri
left a comment
There was a problem hiding this comment.
A couple of nit-picks but overall looks good to me. I'd rather see those tests in JS suite, they are about API testing, not unit testing, but I get that your are following bad precedence in chttpd_db_test.erl. The view bits, however, need to go into own suite, something like chttpd_view_test.erl, it's not good to lump everything together.
| path_parts=[_, OP, <<"queries">>]}=Req, Db) when ?IS_ALL_DOCS(OP) -> | ||
| Props = chttpd:json_body_obj(Req), | ||
| case couch_mrview_util:get_view_queries(Props) of | ||
| Queries when Queries =/= undefined -> |
There was a problem hiding this comment.
Change order here to make undefined match first, you can avoid a repetitive guard that way.
| <<"POST body must include `queries` parameter.">>}) | ||
| end; | ||
|
|
||
| db_req(#httpd{path_parts=[_, _OP, <<"queries">>]}=Req, |
There was a problem hiding this comment.
It's rather weird you are using guard on underscored var, change _OP to a proper variable name.
| chttpd:validate_ctype(Req, "application/json"), | ||
| Props = couch_httpd:json_body_obj(Req), | ||
| case couch_mrview_util:get_view_queries(Props) of | ||
| Queries when Queries =/= undefined -> |
There was a problem hiding this comment.
Same here, switch the match order.
| fun should_succeed_on_local_docs_with_queries_keys/1, | ||
| fun should_succeed_on_local_docs_with_queries_limit_skip/1, | ||
| fun should_succeed_on_local_docs_with_multiple_queries/1, | ||
| fun should_succeed_on_view_with_queries_keys/1, |
There was a problem hiding this comment.
Those three tests doesn't belong to chttpd_db_test.erl, they are not testing chttpd db functionality, but views functionality.
| -define(DESTHEADER1, {"Destination", "foo%E5%95%8Abar"}). | ||
| -define(DESTHEADER2, {"Destination", "foo%2Fbar%23baz%3Fpow%3Afiz"}). | ||
|
|
||
|
|
eiri
left a comment
There was a problem hiding this comment.
lgtm. Don't forget to remove that accidental empty line and squash before merging.
- Add _all_docs/queries endpoint,
- Add _design_docs/queries endpoint,
- Add _local_docs/queries endpoint, and
- Add _design/{ddoc}/_view/{viewname}/queries endpoint
Fixes apache#820
fe6c197 to
36ecf92
Compare
|
Thanks @eiri. Removed empty line and squashed commits. Passed CI. Merged it. |
Overview
Allow to POST to
/{db}/_all_docs/queriesand specify a queries list in the body, the same way you can do/{db}/_design_docs/queries/{db}/_local_docs/queries/{db}/_design/{ddoc}/_view/{viewname}/queriesmultiple_queries.json looks like
Testing recommendations
Related Issues or Pull Requests
#820
#1032
#1143
apache/couchdb-documentation#241
Checklist
Queries endpoint support couchdb-documentation#241