couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject [3/3] couchdb commit: updated refs/heads/1.x.x to 7046724
Date Fri, 31 Oct 2014 02:32:59 GMT
jquery.couch: fix document copying

To COPY a doc the client must specify the target doc id in Destination
header. Additionally, it may add the revision parameter if document
already exists and we want to copy over it.


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/f9095e7d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/f9095e7d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/f9095e7d

Branch: refs/heads/1.x.x
Commit: f9095e7dc3caff6849e0e011d9459c0f61c85cbf
Parents: c3c9588
Author: Alexander Shorin <kxepal@apache.org>
Authored: Wed Oct 29 19:01:17 2014 +0300
Committer: Alexander Shorin <kxepal@apache.org>
Committed: Fri Oct 31 05:31:39 2014 +0300

----------------------------------------------------------------------
 share/www/script/jquery.couch.js | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/f9095e7d/share/www/script/jquery.couch.js
----------------------------------------------------------------------
diff --git a/share/www/script/jquery.couch.js b/share/www/script/jquery.couch.js
index ffbad34..21b151e 100644
--- a/share/www/script/jquery.couch.js
+++ b/share/www/script/jquery.couch.js
@@ -734,6 +734,16 @@
          */
         copyDoc: function(docId, options, ajaxOptions) {
           ajaxOptions = $.extend(ajaxOptions, {
+            beforeSend: function(XMLHttpRequest) {
+              if (!options || !options.docid) {
+                  throw "Target docid required";
+              }
+              var header = options.docid;
+              if (options.rev) {
+                  header += '?rev=' + options.rev
+              }
+              XMLHttpRequest.setRequestHeader("Destination", header);
+            },
             complete: function(req) {
               var resp = $.parseJSON(req.responseText);
               if (req.status == 201) {


Mime
View raw message