jiangphcn opened a new pull request #1222: [WIP] Support queries for endpoints URL: https://github.com/apache/couchdb/pull/1222 <!-- Thank you for your contribution! Please file this form by replacing the Markdown comments with your text. If a section needs no action - remove it. Also remember, that CouchDB uses the Review-Then-Commit (RTC) model of code collaboration. Positive feedback is represented +1 from committers and negative is a -1. The -1 also means veto, and needs to be addressed to proceed. Once there are no objections, the PR can be merged by a CouchDB committer. See: http://couchdb.apache.org/bylaws.html#decisions for more info. --> ## Overview <!-- Please give a short brief for the pull request, what problem it solves or how it makes things better. --> Allow to POST to `/{db}/_all_docs/queries` and specify a queries list in the body, the same way you can do for design documents `/{db}/_design_docs/queries` and a regular MapReduce view `/{db}/_design/{ddoc}/_view/{viewname}/queries` ``` curl -u foo:bar -H "Content-Type: application/json" -X POST -d @multiple_queries.json http://localhost:15984/db/_all_docs/queries {"results":[ {"total_rows":30,"rows":[ {"id":"point2","key":"point2","value":{"rev":"1-d942f0ce01647aa0f46518b213b5628e"}}, {"id":"point3","key":"point3","value":{"rev":"1-721fead6e6c8d811a225d5a62d08dfd0"}} ]}, {"total_rows":30,"offset":2,"rows":[ {"id":"point11","key":"point11","value":{"rev":"1-ffb6c2ae737918f8f911e1fce668333e"}}, {"id":"point12","key":"point12","value":{"rev":"1-c32d315f69ce72128244a60d0cbe4628"}}, {"id":"point13","key":"point13","value":{"rev":"1-a9b955ca17f553398cd877629e803c5d"}}, {"id":"point14","key":"point14","value":{"rev":"1-2f2aa0db2a8c35754e7ab2308940f60c"}}, {"id":"point15","key":"point15","value":{"rev":"1-247191505d8fa6b4b9dc426321987b17"}} ]} ]} ``` multiple_queries.json looks like ``` { "queries": [ { "keys": [ "point2", "point3" ] }, { "limit": 5, "skip": 2 } ] } ``` ## Testing recommendations <!-- Describe how we can test your changes. Does it provides any behaviour that the end users could notice? --> ``` make check skip_deps+=couch_epi apps=chttpd tests=all_test_ Compiled test/chttpd_db_test.erl Running test function(s): chttpd_db_test:all_db_test_/0 ======================== EUnit ======================== chttpd db tests Application crypto was left running! chttpd_db_test:91: should_return_ok_true_on_bulk_update...[0.132 s] ok chttpd_db_test:118: should_accept_live_as_an_alias_for_continuous...[0.071 s] ok chttpd_db_test:133: should_return_404_for_delete_att_on_notadoc...[0.007 s] ok chttpd_db_test:155: should_return_409_for_del_att_without_rev...[0.089 s] ok chttpd_db_test:173: should_return_200_for_del_att_with_rev...[0.072 s] ok chttpd_db_test:194: should_return_409_for_put_att_nonexistent_rev...[0.024 s] ok chttpd_db_test:209: should_return_update_seq_when_set_on_all_docs...[0.118 s] ok chttpd_db_test:223: should_not_return_update_seq_when_unset_on_all_docs...[0.098 s] ok chttpd_db_test:237: should_return_correct_id_on_doc_copy...[0.115 s] ok chttpd_db_test:268: should_return_400_for_bad_engine...[0.003 s] ok chttpd_db_test:280: should_succeed_on_all_docs_with_queries_keys...[0.299 s] ok chttpd_db_test:294: should_succeed_on_all_docs_with_queries_limit_skip...[0.301 s] ok chttpd_db_test:309: should_succeed_on_all_docs_with_multiple_queries...[0.288 s] ok chttpd_db_test:327: should_succeed_on_design_docs_with_queries_keys...[0.301 s] ok chttpd_db_test:342: should_succeed_on_design_docs_with_queries_limit_skip...[0.277 s] ok chttpd_db_test:357: should_succeed_on_design_docs_with_multiple_queries...[0.277 s] ok chttpd_db_test:375: should_succeed_on_view_with_queries_keys...[0.655 s] ok chttpd_db_test:393: should_succeed_on_view_with_queries_limit_skip...[0.317 s] ok chttpd_db_test:412: should_succeed_on_view_with_multiple_queries...[0.360 s] ok [os_mon] cpu supervisor port (cpu_sup): Erlang has closed [done in 6.749 s] ======================================================= All 19 tests passed. ``` ## Related Issues or Pull Requests <!-- If your changes affects multiple components in different repositories please put links to those issues or pull requests here. --> https://github.com/apache/couchdb/issues/820 https://github.com/apache/couchdb/pull/1032 https://github.com/apache/couchdb/pull/1143 ## Checklist - [X] Code is written and works correctly; - [X] Changes are covered by tests; - [ ] Documentation reflects the changes;
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
