summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Christopher Anderson <jchris@apache.org>2009-04-15 23:20:16 +0000
committerJohn Christopher Anderson <jchris@apache.org>2009-04-15 23:20:16 +0000
commitfe46473849e51934063c0e3216e796410d5019bc (patch)
treef5b94b34116556e5efa8d68aa2a8154cc7e39b7e
parent21fc2ebcbf49cdbc8a81442e50072f5c88e80965 (diff)
add bulkSave method to jquery.couch.js
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@765419 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--share/www/script/jquery.couch.js20
1 files changed, 19 insertions, 1 deletions
diff --git a/share/www/script/jquery.couch.js b/share/www/script/jquery.couch.js
index d6aa512e..559fafd4 100644
--- a/share/www/script/jquery.couch.js
+++ b/share/www/script/jquery.couch.js
@@ -238,7 +238,7 @@
contentType: "application/json",
dataType: "json", data: toJSON(doc),
complete: function(req) {
- var resp = $.httpData(req, "json")
+ var resp = $.httpData(req, "json");
doc._id = resp.id;
doc._rev = resp.rev;
if (req.status == 201) {
@@ -251,6 +251,24 @@
}
});
},
+ bulkSave: function(docs, options) {
+ options = options || {};
+ $.ajax({
+ type: 'POST', url: this.uri + "_bulk_docs" + encodeOptions(options),
+ contentType: "application/json",
+ dataType: "json", data: toJSON({docs: docs}),
+ complete: function(req) {
+ var resp = $.httpData(req, "json");
+ if (req.status == 201) {
+ if (options.success) options.success(resp);
+ } else if (options.error) {
+ options.error(req.status, resp.error, resp.reason);
+ } else {
+ alert("The documents could not be saved: " + resp.reason);
+ }
+ }
+ });
+ },
removeDoc: function(doc, options) {
options = options || {};
$.ajax({