couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject jquery-couch commit: updated refs/heads/master to dac654b
Date Fri, 31 Oct 2014 03:03:21 GMT
Repository: couchdb-jquery-couch
Updated Branches:
  refs/heads/master ec5fa1394 -> dac654b0e


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-jquery-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-jquery-couch/commit/dac654b0
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-jquery-couch/tree/dac654b0
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-jquery-couch/diff/dac654b0

Branch: refs/heads/master
Commit: dac654b0e526db5d27d57115859447b31cefbcb0
Parents: ec5fa13
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 06:01:50 2014 +0300

----------------------------------------------------------------------
 jquery.couch.js | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-jquery-couch/blob/dac654b0/jquery.couch.js
----------------------------------------------------------------------
diff --git a/jquery.couch.js b/jquery.couch.js
index a46e05d..f368b2a 100644
--- a/jquery.couch.js
+++ b/jquery.couch.js
@@ -736,6 +736,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