[Couchdb Wiki] Update of "Frequently asked questions" by JanLehnardt
Dear Wiki user, You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification. The following page has been changed by JanLehnardt: http://wiki.apache.org/couchdb/Frequently_asked_questions The comment on the change is: Add FaQ for relationships / joins -- === Views === * [#update_views_more_often I want to update my view indexes more often than only when a user reads it. How do I do that best?] * [#slow_view_building Creating my view index takes ages, WTF?] + * [#relationships How do I model relationships in CouchDB? / Where are my JOINs?] === Security === * [#secure_remote_server I use CouchDB on a remote server and I don't want it to listen on a public port for security reasons. Is there a way to connect to it from my local machine or can I still use Futon with it?] @@ -178, +179 @@ 3) You are using Erlang release R11B (or 5.5.x). Update to at least R12B-3 (or 5.6.3). + [[Anchor(relationships)]] + == How do I model relationships in CouchDB? / Where are my JOINs? == + + See: http://www.cmlenz.net/archives/2007/10/couchdb-joins + [[Anchor(finding_the_logfiles)]] == Where are the Couchdb logfiles located? ==
svn commit: r738903 - /couchdb/trunk/foo
Author: nslater Date: Thu Jan 29 16:00:00 2009 New Revision: 738903 URL: http://svn.apache.org/viewvc?rev=738903&view=rev Log: testing testing Added: couchdb/trunk/foo Added: couchdb/trunk/foo URL: http://svn.apache.org/viewvc/couchdb/trunk/foo?rev=738903&view=auto == (empty)
svn commit: r738928 - /couchdb/trunk/foo
Author: nslater Date: Thu Jan 29 16:51:38 2009 New Revision: 738928 URL: http://svn.apache.org/viewvc?rev=738928&view=rev Log: more testing Removed: couchdb/trunk/foo
svn commit: r739047 [1/2] - in /couchdb/trunk: ./ bin/ share/www/script/ src/couchdb/ src/ibrowse/ utils/
Author: jchris Date: Thu Jan 29 22:15:48 2009 New Revision: 739047 URL: http://svn.apache.org/viewvc?rev=739047&view=rev Log: Replacement of inets with ibrowse. Fixes COUCHDB-179 and enhances replication. Thanks Jason Davies and Adam Kocoloski for the fix, Maximillian Dornseif for reporting. Added: couchdb/trunk/src/ibrowse/ couchdb/trunk/src/ibrowse/Makefile.am (with props) couchdb/trunk/src/ibrowse/ibrowse.app couchdb/trunk/src/ibrowse/ibrowse.erl couchdb/trunk/src/ibrowse/ibrowse.hrl couchdb/trunk/src/ibrowse/ibrowse_app.erl couchdb/trunk/src/ibrowse/ibrowse_http_client.erl couchdb/trunk/src/ibrowse/ibrowse_lb.erl couchdb/trunk/src/ibrowse/ibrowse_lib.erl couchdb/trunk/src/ibrowse/ibrowse_sup.erl couchdb/trunk/src/ibrowse/ibrowse_test.erl Modified: couchdb/trunk/CHANGES couchdb/trunk/Makefile.am couchdb/trunk/NOTICE couchdb/trunk/THANKS couchdb/trunk/bin/Makefile.am couchdb/trunk/bin/couchdb.tpl.in couchdb/trunk/configure.ac couchdb/trunk/share/www/script/couch_tests.js couchdb/trunk/src/couchdb/couch.app.tpl.in couchdb/trunk/src/couchdb/couch_httpd.erl couchdb/trunk/src/couchdb/couch_httpd_db.erl couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl couchdb/trunk/src/couchdb/couch_rep.erl couchdb/trunk/src/couchdb/couch_server_sup.erl couchdb/trunk/utils/Makefile.am Modified: couchdb/trunk/CHANGES URL: http://svn.apache.org/viewvc/couchdb/trunk/CHANGES?rev=739047&r1=739046&r2=739047&view=diff == --- couchdb/trunk/CHANGES (original) +++ couchdb/trunk/CHANGES Thu Jan 29 22:15:48 2009 @@ -28,6 +28,8 @@ dramatically. The fix keeps only one document in the write queue at a time. * Fix for databases sometimes incorrectly reporting that they contain 0 documents after compaction. + * CouchDB now uses ibrowse instead of inets for its internal HTTP client + implementation. This means better replication stability. HTTP Interface: Modified: couchdb/trunk/Makefile.am URL: http://svn.apache.org/viewvc/couchdb/trunk/Makefile.am?rev=739047&r1=739046&r2=739047&view=diff == --- couchdb/trunk/Makefile.am (original) +++ couchdb/trunk/Makefile.am Thu Jan 29 22:15:48 2009 @@ -10,7 +10,7 @@ ## License for the specific language governing permissions and limitations ## under the License. -SUBDIRS = bin etc src/couchdb src/mochiweb share test var utils +SUBDIRS = bin etc src/couchdb src/ibrowse src/mochiweb share test var utils localdoc_DATA = AUTHORS.gz BUGS.gz CHANGES.gz NEWS.gz README.gz THANKS.gz Modified: couchdb/trunk/NOTICE URL: http://svn.apache.org/viewvc/couchdb/trunk/NOTICE?rev=739047&r1=739046&r2=739047&view=diff == --- couchdb/trunk/NOTICE (original) +++ couchdb/trunk/NOTICE Thu Jan 29 22:15:48 2009 @@ -21,3 +21,9 @@ * MochiWeb (http://code.google.com/p/mochiweb/) Copyright 2007, Mochi Media Coporation + + * ibrowse + (http://jungerl.cvs.sourceforge.net/viewvc/jungerl/jungerl/lib/ibrowse/) + + Copyright 2008, Chandrashekhar Mullaparthi + This ASF redistribution is consistent with the terms of the BSD License. \ No newline at end of file Modified: couchdb/trunk/THANKS URL: http://svn.apache.org/viewvc/couchdb/trunk/THANKS?rev=739047&r1=739046&r2=739047&view=diff == --- couchdb/trunk/THANKS (original) +++ couchdb/trunk/THANKS Thu Jan 29 22:15:48 2009 @@ -12,7 +12,9 @@ * Yoan Blanc * Paul Carey * Benoit Chesneau + * Jason Davies * Paul Joseph Davis + * Maximillian Dornseif * Michael Gottesman * Michael Hendricks * Till Klampaeckel Modified: couchdb/trunk/bin/Makefile.am URL: http://svn.apache.org/viewvc/couchdb/trunk/bin/Makefile.am?rev=739047&r1=739046&r2=739047&view=diff == --- couchdb/trunk/bin/Makefile.am (original) +++ couchdb/trunk/bin/Makefile.am Thu Jan 29 22:15:48 2009 @@ -28,8 +28,9 @@ -e "s|%ICU_CONFIG%|$(ICU_CONFIG)|g" \ -e "s|%bindir%|@bindir@|g" \ -e "s|%localerlanglibdir%|@localerlanglibdir@|g" \ - -e "s|%mochiwebebindir%|cou...@version@/ebin|g" \ - -e "s|%couchdbebindir%|mochiweb-r82/ebin|g" \ + -e "s|%couchdbebindir%|cou...@version@/ebin|g" \ + -e "s|%mochiwebebindir%|mochiweb-r82/ebin|g" \ + -e "s|%ibrowseebindir%|ibrowse-1.4.1/ebin|g" \ -e "s|%defaultini%|default.ini|g" \ -e "s|%localini%|local.ini|g" \ -e "s|%localconfdir%|@localconfdir@|g" \ Modified: couchdb/trunk/bin/couchdb.tpl.in URL: http://svn.apache.org/viewvc/couchdb/trunk/bin/couchdb.tpl.in?rev=739047&r1=739046&r2=739047&view=diff ===
svn commit: r739081 - /couchdb/trunk/src/ibrowse/
Author: jchris Date: Thu Jan 29 23:28:04 2009 New Revision: 739081 URL: http://svn.apache.org/viewvc?rev=739081&view=rev Log: svn:ignore for ibrowse build products Modified: couchdb/trunk/src/ibrowse/ (props changed) Propchange: couchdb/trunk/src/ibrowse/ -- --- svn:ignore (added) +++ svn:ignore Thu Jan 29 23:28:04 2009 @@ -0,0 +1,3 @@ +Makefile +Makefile.in +*.beam
svn commit: r739133 - in /couchdb/trunk: share/www/script/couch_tests.js src/couchdb/couch_httpd_db.erl
Author: jchris Date: Fri Jan 30 01:40:38 2009 New Revision: 739133 URL: http://svn.apache.org/viewvc?rev=739133&view=rev Log: POST to create docs returns a Location header. fixes COUCHDB-8 Modified: couchdb/trunk/share/www/script/couch_tests.js couchdb/trunk/src/couchdb/couch_httpd_db.erl Modified: couchdb/trunk/share/www/script/couch_tests.js URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/couch_tests.js?rev=739133&r1=739132&r2=739133&view=diff == --- couchdb/trunk/share/www/script/couch_tests.js [utf-8] (original) +++ couchdb/trunk/share/www/script/couch_tests.js [utf-8] Fri Jan 30 01:40:38 2009 @@ -140,6 +140,18 @@ // make sure we can still open T(db.open(existingDoc._id, {rev: existingDoc._rev}) != null); + +// test that the POST response has a Location header +var xhr = CouchDB.request("POST", "/test_suite_db", { + body: JSON.stringify({"foo":"bar"}) +}); +var resp = JSON.parse(xhr.responseText); +T(resp.ok); +var loc = xhr.getResponseHeader("Location"); +T(loc, "should have a Location header"); +var locs = loc.split('/'); +T(locs[4] == resp.id); +T(locs[3] == "test_suite_db"); }, delayed_commits: function(debug) { Modified: couchdb/trunk/src/couchdb/couch_httpd_db.erl URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_db.erl?rev=739133&r1=739132&r2=739133&view=diff == --- couchdb/trunk/src/couchdb/couch_httpd_db.erl (original) +++ couchdb/trunk/src/couchdb/couch_httpd_db.erl Fri Jan 30 01:40:38 2009 @@ -18,7 +18,7 @@ -import(couch_httpd, [send_json/2,send_json/3,send_json/4,send_method_not_allowed/2, start_json_response/2,send_chunk/2,end_json_response/1, -start_chunked_response/3]). +start_chunked_response/3, absolute_uri/2]). -record(doc_query_args, { options = [], @@ -76,11 +76,13 @@ {ok, DbInfo} = couch_db:get_db_info(Db), send_json(Req, {DbInfo}); -db_req(#httpd{method='POST',path_parts=[_DbName]}=Req, Db) -> +db_req(#httpd{method='POST',path_parts=[DbName]}=Req, Db) -> Doc = couch_doc:from_json_obj(couch_httpd:json_body(Req)), DocId = couch_util:new_uuid(), {ok, NewRev} = couch_db:update_doc(Db, Doc#doc{id=DocId, revs=[]}, []), -send_json(Req, 201, {[ +DocUrl = absolute_uri(Req, +binary_to_list(<<"/",DbName/binary,"/",DocId/binary>>)), +send_json(Req, 201, [{"Location", DocUrl}], {[ {ok, true}, {id, DocId}, {rev, NewRev}
svn commit: r739153 - /couchdb/trunk/src/couchdb/couch_httpd.erl
Author: jchris Date: Fri Jan 30 03:02:44 2009 New Revision: 739153 URL: http://svn.apache.org/viewvc?rev=739153&view=rev Log: use the config setting for max document size. fixes COUCHDB-60 Modified: couchdb/trunk/src/couchdb/couch_httpd.erl Modified: couchdb/trunk/src/couchdb/couch_httpd.erl URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=739153&r1=739152&r2=739153&view=diff == --- couchdb/trunk/src/couchdb/couch_httpd.erl (original) +++ couchdb/trunk/src/couchdb/couch_httpd.erl Fri Jan 30 03:02:44 2009 @@ -26,9 +26,6 @@ -export([default_authentication_handler/1,special_test_authentication_handler/1]). -% Maximum size of document PUT request body (4GB) --define(MAX_DOC_SIZE, (4*1024*1024*1024)). - start_link() -> % read config and register for configuration changes @@ -264,10 +261,13 @@ MochiReq:recv(Len). body(#httpd{mochi_req=MochiReq}) -> -MochiReq:recv_body(?MAX_DOC_SIZE). +% Maximum size of document PUT request body (4GB) +MaxSize = list_to_integer( +couch_config:get("couchdb", "max_document_size", "4294967296")), +MochiReq:recv_body(MaxSize). -json_body(#httpd{mochi_req=MochiReq}) -> -?JSON_DECODE(MochiReq:recv_body(?MAX_DOC_SIZE)). +json_body(Httpd) -> +?JSON_DECODE(body(Httpd)). doc_etag(#doc{revs=[DiskRev|_]}) -> "\"" ++ binary_to_list(DiskRev) ++ "\"".
[Couchdb Wiki] Update of "HTTP view API" by ChrisAnderson
Dear Wiki user, You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification. The following page has been changed by ChrisAnderson: http://wiki.apache.org/couchdb/HTTP_view_API The comment on the change is: document stale=ok, closes COUCHDB-77 -- * endkey=keyvalue * endkey_docid=docid * limit=max rows to return ''This used to be called "count" previous to Trunk SVN r731159'' - * update=false + * stale=ok * descending=true * skip=number of rows to skip * group=true ''Version 0.8.0 and forward'' @@ -168, +168 @@ The ''skip'' option should only be used with small values, as skipping a large range of documents this way is inefficient (it scans the index from the startkey and then skips N elements, but still needs to read all the index values to do that). For efficient paging use ''startkey'' and/or ''startkey_docid''. - The ''update'' option can be used for higher performance at the cost of possibly not seeing the all latest data. If you set the ''update'' option to ''false'', CouchDB will not perform any refreshing on the view that may be necessary. + The ''stale'' option can be used for higher performance at the cost of possibly not seeing the all latest data. If you set the ''stale'' option to ''ok'', CouchDB may not perform any refreshing on the view that may be necessary. Using this option essentially tells CouchDB that if a reference to the view index is available in memory, go ahead and use it, even if it may be out of date. The result is that for a highly trafficked view, end users can see lower latency, although they may not get the latest data. However, if there is no view index pointer in memory, the behavior with this option is that same as the behavior without the option. If your application use ''stale=ok'' for end-user queries, you'll need either a cron or a notification process like the one described in ["Regenerating views on update"], which queries without ''stale=ok'' to ensure that the view is kept reasonably up to date. View rows are sorted by the key; specifying ''descending=true'' will reverse their order. Note that the ''descending'' option is applied before any key filtering, so you may need to swap the values of the ''startkey'' and ''endkey'' options to get the expected results. The sorting itself is described in ViewCollation.
svn commit: r739157 - in /couchdb/trunk: share/www/script/couch_tests.js src/couchdb/couch_httpd.erl src/couchdb/couch_httpd_db.erl
Author: jchris Date: Fri Jan 30 03:50:44 2009 New Revision: 739157 URL: http://svn.apache.org/viewvc?rev=739157&view=rev Log: swap 412 ad 409 error codes. fixes COUCHDB-226 Modified: couchdb/trunk/share/www/script/couch_tests.js couchdb/trunk/src/couchdb/couch_httpd.erl couchdb/trunk/src/couchdb/couch_httpd_db.erl Modified: couchdb/trunk/share/www/script/couch_tests.js URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/couch_tests.js?rev=739157&r1=739156&r2=739157&view=diff == --- couchdb/trunk/share/www/script/couch_tests.js [utf-8] (original) +++ couchdb/trunk/share/www/script/couch_tests.js [utf-8] Fri Jan 30 03:50:44 2009 @@ -34,9 +34,9 @@ db.createDb(); -// PUT on existing DB should return 409 instead of 500 +// PUT on existing DB should return 412 instead of 500 xhr = CouchDB.request("PUT", "/test_suite_db/"); -T(xhr.status == 409); +T(xhr.status == 412); if (debug) debugger; // Get the database info, check the db_name @@ -443,7 +443,7 @@ var xhr = CouchDB.request("COPY", "/test_suite_db/doc_to_be_copied", { headers: {"Destination":"doc_to_be_overwritten"} }); -T(xhr.status == 412); // conflict +T(xhr.status == 409); // conflict var rev = db.open("doc_to_be_overwritten")._rev; var xhr = CouchDB.request("COPY", "/test_suite_db/doc_to_be_copied", { @@ -958,7 +958,7 @@ // test without rev, should fail var xhr = CouchDB.request("DELETE", "/test_suite_db/bin_doc2/foo2.txt"); -T(xhr.status == 412); +T(xhr.status == 409); // test with rev, should not fail var xhr = CouchDB.request("DELETE", "/test_suite_db/bin_doc2/foo2.txt?rev=" + rev); @@ -982,7 +982,7 @@ headers:{"Content-Type":"text/plain;charset=utf-8"}, body:bin_data }); -T(xhr.status == 412); +T(xhr.status == 409); var xhr = CouchDB.request("PUT", "/test_suite_db/bin_doc3/attachment.txt?rev=" + rev, { headers:{"Content-Type":"text/plain;charset=utf-8"}, @@ -1079,7 +1079,7 @@ headers:{"Content-Type":"text/plain;charset=utf-8"}, body:"Just some text" }); - T(xhr.status == 412); + T(xhr.status == 409); var xhr = CouchDB.request("PUT", "/"+dbName+"/bin_doc/foo/bar2.txt?rev=" + binAttDoc._rev, { body:"This is no base64 encoded text", @@ -1148,7 +1148,7 @@ headers:{"Content-Type":"text/plain;charset=utf-8"}, body:"Just some text" }); - T(xhr.status == 412); + T(xhr.status == 409); var xhr = CouchDB.request("PUT", "/"+dbName+"/_design%2Fbin_doc/foo/bar2.txt?rev=" + binAttDoc._rev, { body:"This is no base64 encoded text", @@ -2292,7 +2292,7 @@ xhr = CouchDB.request("PUT", "/test_suite_db/1", { body: "{}" }); -T(xhr.status == 412) +T(xhr.status == 409) // verify get w/Etag xhr = CouchDB.request("GET", "/test_suite_db/1", { @@ -2308,7 +2308,7 @@ xhr = CouchDB.request("DELETE", "/test_suite_db/1", { headers: {"if-match": etagOld} }); -T(xhr.status == 412); +T(xhr.status == 409); //now do it for real xhr = CouchDB.request("DELETE", "/test_suite_db/1", { Modified: couchdb/trunk/src/couchdb/couch_httpd.erl URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=739157&r1=739156&r2=739157&view=diff == --- couchdb/trunk/src/couchdb/couch_httpd.erl (original) +++ couchdb/trunk/src/couchdb/couch_httpd.erl Fri Jan 30 03:50:44 2009 @@ -371,7 +371,7 @@ send_error(Req, {not_found, Reason}) -> send_error(Req, 404, <<"not_found">>, Reason); send_error(Req, conflict) -> -send_error(Req, 412, <<"conflict">>, <<"Document update conflict.">>); +send_error(Req, 409, <<"conflict">>, <<"Document update conflict.">>); send_error(Req, {forbidden, Msg}) -> send_json(Req, 403, {[{<<"error">>, <<"forbidden">>}, @@ -397,7 +397,7 @@ {[{<<"error">>, proplists:get_value(<<"error">>, Props)}, {<<"reason">>, proplists:get_value(<<"reason">>, Props)}]}); send_error(Req, file_exists) -> -send_error(Req, 409, <<"file_exists">>, <<"The database could not be " +send_error(Req, 412, <<"file_exists">>, <<"The database could not be " "created, the file already exists.">>); send_error(Req, {Error, Reason}) -> send_error(Req, 500, Error, Reason); Modified: couchdb/trunk/src/couchdb/couch_httpd_db.erl URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_db.erl?rev=739157&r1=739156&r2=739157&view=diff == --- couchdb/trunk/src/couchdb/couch_httpd_db.erl (original) +++ couchdb/trunk/src/couchdb/couch_httpd_db.erl Fri Jan 30 03:50:44 2009 @@ -369,7 +369,7 @@ db_doc_req(#http
svn commit: r739169 - /couchdb/trunk/src/couchdb/couch_httpd_view.erl
Author: jchris Date: Fri Jan 30 04:41:12 2009 New Revision: 739169 URL: http://svn.apache.org/viewvc?rev=739169&view=rev Log: cleanup long lines Modified: couchdb/trunk/src/couchdb/couch_httpd_view.erl Modified: couchdb/trunk/src/couchdb/couch_httpd_view.erl URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_view.erl?rev=739169&r1=739168&r2=739169&view=diff == --- couchdb/trunk/src/couchdb/couch_httpd_view.erl (original) +++ couchdb/trunk/src/couchdb/couch_httpd_view.erl Fri Jan 30 04:41:12 2009 @@ -268,10 +268,14 @@ fwd -> Args#view_query_args { direction = rev, -start_key = reverse_key_default(Args#view_query_args.start_key), -start_docid = reverse_key_default(Args#view_query_args.start_docid), -end_key = reverse_key_default(Args#view_query_args.end_key), -end_docid = reverse_key_default(Args#view_query_args.end_docid)}; +start_key = +reverse_key_default(Args#view_query_args.start_key), +start_docid = +reverse_key_default(Args#view_query_args.start_docid), +end_key = +reverse_key_default(Args#view_query_args.end_key), +end_docid = +reverse_key_default(Args#view_query_args.end_docid)}; _ -> Args %already reversed end;
svn commit: r739170 - in /couchdb/trunk: share/www/script/couch_tests.js src/couchdb/couch_btree.erl
Author: jchris Date: Fri Jan 30 04:57:44 2009 New Revision: 739170 URL: http://svn.apache.org/viewvc?rev=739170&view=rev Log: all_docs view with descending=true works properly now. fix COUCHDB-109 Modified: couchdb/trunk/share/www/script/couch_tests.js couchdb/trunk/src/couchdb/couch_btree.erl Modified: couchdb/trunk/share/www/script/couch_tests.js URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/couch_tests.js?rev=739170&r1=739169&r2=739170&view=diff == --- couchdb/trunk/share/www/script/couch_tests.js [utf-8] (original) +++ couchdb/trunk/share/www/script/couch_tests.js [utf-8] Fri Jan 30 04:57:44 2009 @@ -577,9 +577,8 @@ } // Check _all_docs with descending=true again (now that there are many docs) -// this fails, see COUCHDB-109 -// var desc = db.allDocs({descending:true}); -// T(desc.total_rows == desc.rows.length); +var desc = db.allDocs({descending:true}); +T(desc.total_rows == desc.rows.length); }, reduce: function(debug) { Modified: couchdb/trunk/src/couchdb/couch_btree.erl URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_btree.erl?rev=739170&r1=739169&r2=739170&view=diff == --- couchdb/trunk/src/couchdb/couch_btree.erl (original) +++ couchdb/trunk/src/couchdb/couch_btree.erl Fri Jan 30 04:57:44 2009 @@ -558,6 +558,8 @@ stream_node(Bt, Reds, PointerInfo, nil, Dir, Fun, Acc) -> stream_node(Bt, Reds, PointerInfo, Dir, Fun, Acc); +stream_node(Bt, Reds, PointerInfo, {}, rev, Fun, Acc) -> +stream_node(Bt, Reds, PointerInfo, rev, Fun, Acc); stream_node(_Bt, _Reds, nil, _StartKey, _Dir, _Fun, Acc) -> {ok, Acc}; stream_node(Bt, Reds, {Pointer, _Reds}, StartKey, Dir, Fun, Acc) ->