couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jch...@apache.org
Subject svn commit: r944570 - /couchdb/trunk/share/www/script/jquery.couch.js
Date Sat, 15 May 2010 05:08:26 GMT
Author: jchris
Date: Sat May 15 05:08:25 2010
New Revision: 944570

URL: http://svn.apache.org/viewvc?rev=944570&view=rev
Log:
jquery.couch.js option to force ensure_full_commit to true or false

Modified:
    couchdb/trunk/share/www/script/jquery.couch.js

Modified: couchdb/trunk/share/www/script/jquery.couch.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/jquery.couch.js?rev=944570&r1=944569&r2=944570&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/jquery.couch.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/jquery.couch.js [utf-8] Sat May 15 05:08:25 2010
@@ -258,6 +258,7 @@
           );
         },
         saveDoc: function(doc, options) {
+          var beforeSend = fullCommit(options);
           options = options || {};
           if (doc._id === undefined) {
             var method = "POST";
@@ -270,6 +271,7 @@
             type: method, url: uri + encodeOptions(options),
             contentType: "application/json",
             dataType: "json", data: toJSON(doc),
+            beforeSend : beforeSend,
             complete: function(req) {
               var resp = $.httpData(req, "json");
               if (req.status == 201) {
@@ -285,7 +287,8 @@
           });
         },
         bulkSave: function(docs, options) {
-          $.extend(options, {successStatus: 201});
+          var beforeSend = fullCommit(options);
+          $.extend(options, {successStatus: 201, beforeSend : beforeSend});
           ajax({
               type: "POST",
               url: this.uri + "_bulk_docs" + encodeOptions(options),
@@ -472,6 +475,16 @@
     }, obj), ajaxOptions));
   }
 
+  function fullCommit(options) {
+    if (typeof options.ensure_full_commit !== "undefined") {
+      var commit = options.ensure_full_commit;
+      delete options.ensure_full_commit;
+      return function(xhr) {
+        xhr.setRequestHeader("X-Couch-Full-Commit", commit.toString());
+      };
+    }
+  };
+
   // Convert a options object to an url query string.
   // ex: {key:'value',key2:'value2'} becomes '?key="value"&key2="value2"'
   function encodeOptions(options) {



Mime
View raw message