summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorJohn Christopher Anderson <jchris@apache.org>2010-05-15 05:08:25 +0000
committerJohn Christopher Anderson <jchris@apache.org>2010-05-15 05:08:25 +0000
commitb71f475d9d42ca2b8a30465cee615d633ce47d55 (patch)
treedff2ba485f4d9daa3b1bdfcbfacbe290ae9e4ff5 /share
parentdd43229e6580520546b364c2cd87d1ffea945e8e (diff)
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
Diffstat (limited to 'share')
-rw-r--r--share/www/script/jquery.couch.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/share/www/script/jquery.couch.js b/share/www/script/jquery.couch.js
index 71560181..5a9541ba 100644
--- a/share/www/script/jquery.couch.js
+++ b/share/www/script/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) {