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 JanLehnardt
Date Mon, 05 Jan 2009 11:19:08 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 JanLehnardt:
http://wiki.apache.org/couchdb/HTTP_Document_API

The comment on the change is:
document COPY & MOVE

------------------------------------------------------------------------------
  
  {"ok":true,"rev":"2839830636"}
  }}}
+ 
+ 
+ == COPY ==
+ 
+ Note that this is a non-standard extension to HTTP.
+ 
+ You can copy documents by sending an HTTP COPY request. This allows you to duplicate the
contents (and attachments) of a document to a new document under a different document id without
first retrieving it from CouchDB. Use the ''Destination'' header to specify the document that
you want to copy to (the target document).
+ 
+ It is not possible to copy documents between databases and it is not (yet) possible to make
bulk copy operations.
+ 
+ {{{
+ COPY /somedatabase/some_doc HTTP/1.1
+ Destination: some_other_doc
+ }}}
+ 
+ If you want to overwrite an existing document, you need to specify the target document's
revision with a ''rev'' parameter in the ''Destination'' header:
+ 
+ {{{
+ COPY /somedatabase/some_doc HTTP/1.1
+ Destination: some_other_doc?rev=rev_id
+ }}}
+ 
+ The response in both cases includes the target document's revision:
+ 
+ {{{
+ HTTP/1.1 201 Created
+ Server: CouchDB/0.9.0a730122-incubating (Erlang OTP/R12B)
+ Etag: "355068078"
+ Date: Mon, 05 Jan 2009 11:12:49 GMT
+ Content-Type: text/plain;charset=utf-8
+ Content-Length: 41
+ Cache-Control: must-revalidate
+ 
+ {"ok":true,"id":"some_other_doc","rev":"355068078"}
+ 
+ }}}
+ 
+ 
+ == MOVE ==
+ 
+ Note that this is a non-standard extension to HTTP.
+ 
+ You can move a document by sending an HTTP MOVE request. This allows you to make the contents
(and attachments) of a document available under a different document id without first retrieving
it from CouchDB. Use the ''Destination'' header to specify the document that you want to move
to (the target document).
+ 
+ Since MOVE is a COPY & DELETE under the hood, you need to provide the revision id of
the document you want to move.
+ 
+ It is not possible to move documents between databases and it is not (yet) possible to make
bulk move operations.
+ 
+ {{{
+ MOVE /somedatabase/some_doc?rev=some_id HTTP/1.1
+ Destination: some_other_doc
+ }}}
+ 
+ If you want to overwrite an existing document, you need to specify the target document's
revision with a ''rev'' parameter in the ''Destination'' header:
+ 
+ {{{
+ MOVE /somedatabase/some_doc?rev=some_id HTTP/1.1
+ Destination: some_other_doc?rev=rev_id
+ }}}
+ 
+ The response in both cases includes the source and the target documents' new revisions:
+ 
+ {{{
+ HTTP/1.1 201 Created
+ Server: CouchDB/0.9.0a730122-incubating (Erlang OTP/R12B)
+ Date: Mon, 05 Jan 2009 11:15:21 GMT
+ Content-Type: text/plain;charset=utf-8
+ Content-Length: 84
+ Cache-Control: must-revalidate
+ 
+ {"ok":true,"new_revs":[{"id":"some_doc","rev":"4201149655"},{"id":"some_other_doc","rev":"3751914507"}]}
+ }}}
+ 
  
  == Attachments ==
  

Mime
View raw message