couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject [12/50] jquery-couch commit: updated refs/heads/import-master to 66dbcbf
Date Tue, 01 Apr 2014 08:52:17 GMT
jquery.couch.js option to force ensure_full_commit to true or false

git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@944570 13f79535-47bb-0310-9956-ffa450edef68


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

Branch: refs/heads/import-master
Commit: 2a2abed9668a6ff7602cd2855d8a26eb79270d9e
Parents: 283b184
Author: John Christopher Anderson <jchris@apache.org>
Authored: Sat May 15 05:08:25 2010 +0000
Committer: Alexander Shorin <kxepal@gmail.com>
Committed: Sat May 15 05:08:25 2010 +0000

----------------------------------------------------------------------
 jquery.couch.js | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-jquery-couch/blob/2a2abed9/jquery.couch.js
----------------------------------------------------------------------
diff --git a/jquery.couch.js b/jquery.couch.js
index d197ba3..5eb0bc3 100644
--- a/jquery.couch.js
+++ b/jquery.couch.js
@@ -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