couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Couchdb Wiki] Update of "HTTP Document API" by BrianCandler
Date Tue, 24 Mar 2009 15:34:31 GMT
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 BrianCandler:
http://wiki.apache.org/couchdb/HTTP_Document_API

The comment on the change is:
Note about multi-document fetch

------------------------------------------------------------------------------
  {"ok":true, "id":"123BAC", "rev":"946B7D1C"}
  }}}
  
+ === Fetch Multiple Documents With a Single Request ===
+ 
+ {{{_all_docs}}} is really a [[HTTP_view_API view]] where each ''key'' is the doc _id, and
each ''value'' is a JSON object containing the rev. This means that:
+ 
+    * By adding {{{?include_docs=true}}} you can get the documents themselves, not just their
id and rev
+    * By adding {{{?startkey="xx"&endkey="yy"}} you can get the documents with keys in
a certain range
+    * By POSTing to _bulk_docs you can get a set of documents with arbitrary keys
+ 
+ {{{
+ $ curl -d '{"keys":["bar","baz"]}' -X POST http://127.0.0.1:5984/foo/_all_docs?include_docs=true
+ {"total_rows":3,"offset":0,"rows":[
+ {"id":"bar","key":"bar","value":{"rev":"1-4057566831"},"doc":{"_id":"bar","_rev":"1-4057566831","name":"jim"}},
+ {"id":"baz","key":"baz","value":{"rev":"1-2842770487"},"doc":{"_id":"baz","_rev":"1-2842770487","name":"trunky"}}
+ ]}
+ 
+ $ curl 'http://127.0.0.1:5984/foo/_all_docs?include_docs=true&startkey="ba"&endkey="bb"'
+ {"total_rows":3,"offset":0,"rows":[
+ {"id":"bar","key":"bar","value":{"rev":"1-4057566831"},"doc":{"_id":"bar","_rev":"1-4057566831","name":"jim"}},
+ {"id":"baz","key":"baz","value":{"rev":"1-2842770487"},"doc":{"_id":"baz","_rev":"1-2842770487","name":"trunky"}}
+ ]}
+ }}}
+ 
  === Modify Multiple Documents With a Single Request ===
  
  CouchDB provides a bulk insert/update feature. To use this, you make a ''POST'' request
to the URI ''/{dbname}/_bulk_docs'', with the request body being a JSON document containing
a list of new documents to be inserted or updated. 
@@ -381, +403 @@

  }}}
  
  
- == Transactional Semantics with Bulk Updates ==
+ ==== Transactional Semantics with Bulk Updates ====
  
  In previous releases of CouchDB, bulk updates were transactional - in particular, all requests
in a bulk update failed if any request failed or was in conflict. There were a couple of problems
with this approach:
  
@@ -454, +476 @@

  }}}
  
  
- == COPY ==
+ === COPY ===
  
  Note that this is a non-standard extension to HTTP.
  
@@ -490, +512 @@

  }}}
  
  
- == MOVE ==
+ === MOVE ===
  
  For a ~6 month period CouchDB trunk between versions 0.8 and 0.9 included the nonstandard
MOVE method. Since MOVE is really just COPY & DELETE and CouchDB can not reasonably guarantee
atomicity between the COPY & MOVE operations on a single or on multiple nodes, this was
removed before the release of CouchDB 0.9.
   

Mime
View raw message