You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by jc...@apache.org on 2009/04/16 01:20:16 UTC

svn commit: r765419 - /couchdb/trunk/share/www/script/jquery.couch.js

Author: jchris
Date: Wed Apr 15 23:20:16 2009
New Revision: 765419

URL: http://svn.apache.org/viewvc?rev=765419&view=rev
Log:
add bulkSave method to jquery.couch.js

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=765419&r1=765418&r2=765419&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/jquery.couch.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/jquery.couch.js [utf-8] Wed Apr 15 23:20:16 2009
@@ -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({