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 ChrisAnderson
Date Wed, 25 Mar 2009 02:12:53 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 ChrisAnderson:
http://wiki.apache.org/couchdb/HTTP_Document_API

The comment on the change is:
cleanup

------------------------------------------------------------------------------
  
  Note that by default the structure is flat; in this case, the ''Activities'' attribute is
structure imposed by the user.
  
- == All Documents ==
  
- To get a listing of all documents in a database, use the special ''_all_docs'' URI. This
is a specialized View so the Querying Options of the ["HTTP_view_API"] apply here.
- 
- 
- {{{
- GET somedatabase/_all_docs HTTP/1.0
- }}}
- 
- Will return a listing of all documents and their revision IDs, ordered by DocID (case sensitive):
- 
- {{{
- HTTP/1.1 200 OK
- Date: Thu, 17 Aug 2006 05:39:28 +0000GMT
- Content-Type: application/json
- Connection: close
- 
- {
-   "total_rows": 3, "offset": 0, "rows": [
-     {"id": "doc1", "key": "doc1", "value": {"rev": "4324BB"}},
-     {"id": "doc2", "key": "doc2", "value": {"rev":"2441HF"}},
-     {"id": "doc3", "key": "doc3", "value": {"rev":"74EC24"}}
-   ]
- }
- }}}
- 
- Use the query argument ''descending=true'' to reverse the order of the output table:
- 
- Will return the same as before but in reverse order:
- 
- {{{
- HTTP/1.1 200 OK
- Date: Thu, 17 Aug 2006 05:39:28 +0000GMT
- Content-Type: application/json
- Connection: close
- 
- {
-   "total_rows": 3, "offset": 0, "rows": [
-     {"id": "doc3", "key": "doc3", "value": {"_rev":"74EC24"}}
-     {"id": "doc2", "key": "doc2", "value": {"_rev":"2441HF"}},
-     {"id": "doc1", "key": "doc1", "value": {"_rev": "4324BB"}},
-   ]
- }
- }}}
- 
- The query string parameters ''startkey'', ''endkey'' and ''limit'' may also be used to limit
the result set. For example:
- 
- {{{
- GET somedatabase/_all_docs?startkey=doc2&limit=2 HTTP/1.0
- }}}
- 
- Will return:
- 
- {{{
- HTTP/1.1 200 OK
- Date: Thu, 17 Aug 2006 05:39:28 +0000GMT
- Content-Type: application/json
- Connection: close
- 
- {
-   "total_rows": 3, "offset": 1, "rows": [
-     {"id": "doc2", "key": "doc2", "value": {"_rev":"2441HF"}},
-     {"id": "doc3", "key": "doc3", "value": {"_rev":"74EC24"}}
-   ]
- }
- }}}
- 
- Use ''endkey'' if you are interested  in a specific range of documents:
- 
- {{{
- GET somedatabase/_all_docs?startkey=doc2&endkey=doc3 HTTP/1.0
- }}}
- 
- This will get keys inbetween and including doc2 and doc3; e.g. ''doc2-b'' and ''doc234''.
- 
- Both approaches can be combined with ''descending'':
- 
- {{{
- GET somedatabase/_all_docs?startkey=doc2&limit=2&descending=true HTTP/1.0
- }}}
- 
- Will return:
- 
- {{{
- HTTP/1.1 200 OK
- Date: Thu, 17 Aug 2006 05:39:28 +0000GMT
- Content-Type: application/json
- Connection: close
- 
- {
-   "total_rows": 3, "offset": 1, "rows": [
-     {"id": "doc3", "key": "doc3", "value": {"_rev":"74EC24"}}
-     {"id": "doc2", "key": "doc2", "value": {"_rev":"2441HF"}},
-   ]
- }
- }}}
- 
- If you add ''include_docs=true'' to a request to ''_all_docs'' not only metadata but also
the documents themselves are returned.
  
  == Working With Documents Over HTTP ==
  
@@ -329, +232 @@

  
  }}}
  
- === Bulk Docs ===
- 
- 
  
  === DELETE ===
  
@@ -399, +299 @@

  
  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.
   
+ 
+ === Bulk Docs ===
+ 
+ For information about editing multiple documents at the same time, see [["HTTP Bulk Document
API"]]
+ 
+ 
+ == All Documents ==
+ 
+ To get a listing of all documents in a database, use the special ''_all_docs'' URI. This
is a specialized View so the Querying Options of the ["HTTP_view_API"] apply here.
+ 
+ 
+ {{{
+ GET somedatabase/_all_docs HTTP/1.0
+ }}}
+ 
+ Will return a listing of all documents and their revision IDs, ordered by DocID (case sensitive):
+ 
+ {{{
+ HTTP/1.1 200 OK
+ Date: Thu, 17 Aug 2006 05:39:28 +0000GMT
+ Content-Type: application/json
+ Connection: close
+ 
+ {
+   "total_rows": 3, "offset": 0, "rows": [
+     {"id": "doc1", "key": "doc1", "value": {"rev": "4324BB"}},
+     {"id": "doc2", "key": "doc2", "value": {"rev":"2441HF"}},
+     {"id": "doc3", "key": "doc3", "value": {"rev":"74EC24"}}
+   ]
+ }
+ }}}
+ 
+ Use the query argument ''descending=true'' to reverse the order of the output table:
+ 
+ Will return the same as before but in reverse order:
+ 
+ {{{
+ HTTP/1.1 200 OK
+ Date: Thu, 17 Aug 2006 05:39:28 +0000GMT
+ Content-Type: application/json
+ Connection: close
+ 
+ {
+   "total_rows": 3, "offset": 0, "rows": [
+     {"id": "doc3", "key": "doc3", "value": {"_rev":"74EC24"}}
+     {"id": "doc2", "key": "doc2", "value": {"_rev":"2441HF"}},
+     {"id": "doc1", "key": "doc1", "value": {"_rev": "4324BB"}},
+   ]
+ }
+ }}}
+ 
+ The query string parameters ''startkey'', ''endkey'' and ''limit'' may also be used to limit
the result set. For example:
+ 
+ {{{
+ GET somedatabase/_all_docs?startkey=doc2&limit=2 HTTP/1.0
+ }}}
+ 
+ Will return:
+ 
+ {{{
+ HTTP/1.1 200 OK
+ Date: Thu, 17 Aug 2006 05:39:28 +0000GMT
+ Content-Type: application/json
+ Connection: close
+ 
+ {
+   "total_rows": 3, "offset": 1, "rows": [
+     {"id": "doc2", "key": "doc2", "value": {"_rev":"2441HF"}},
+     {"id": "doc3", "key": "doc3", "value": {"_rev":"74EC24"}}
+   ]
+ }
+ }}}
+ 
+ Use ''endkey'' if you are interested  in a specific range of documents:
+ 
+ {{{
+ GET somedatabase/_all_docs?startkey=doc2&endkey=doc3 HTTP/1.0
+ }}}
+ 
+ This will get keys inbetween and including doc2 and doc3; e.g. ''doc2-b'' and ''doc234''.
+ 
+ Both approaches can be combined with ''descending'':
+ 
+ {{{
+ GET somedatabase/_all_docs?startkey=doc2&limit=2&descending=true HTTP/1.0
+ }}}
+ 
+ Will return:
+ 
+ {{{
+ HTTP/1.1 200 OK
+ Date: Thu, 17 Aug 2006 05:39:28 +0000GMT
+ Content-Type: application/json
+ Connection: close
+ 
+ {
+   "total_rows": 3, "offset": 1, "rows": [
+     {"id": "doc3", "key": "doc3", "value": {"_rev":"74EC24"}}
+     {"id": "doc2", "key": "doc2", "value": {"_rev":"2441HF"}},
+   ]
+ }
+ }}}
+ 
+ If you add ''include_docs=true'' to a request to ''_all_docs'' not only metadata but also
the documents themselves are returned.
  
  == Attachments ==
  

Mime
View raw message