From fe46473849e51934063c0e3216e796410d5019bc Mon Sep 17 00:00:00 2001 From: John Christopher Anderson Date: Wed, 15 Apr 2009 23:20:16 +0000 Subject: add bulkSave method to jquery.couch.js git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@765419 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/jquery.couch.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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({ -- cgit v1.2.3