0

I am using couchapp with CouchDB to store information about connections between nodes. I am trying to save an array of json data. If the number of items in the array is less than 2000, everything works fine. Unfortunately, bigger amounts of data cause errors:

POST http://localhost:5984/graph_project/  jquery.js:8240
send jquery.js:8240
jQuery.extend.ajax jquery.js:7719
saveDoc jquery.couch.js:627
writeJSONtoDb main.js:185
CSVArrayToJson main.js:335
(anonymous function)

Uncaught TypeError: Cannot read property 'error' of null jquery.couch.js:649
$.ajax.complete jquery.couch.js:649
fire jquery.js:1075
self.fireWith jquery.js:1193
done jquery.js:7553
callback

and only part of the data is saved correctly.

The code looks like this:

function writeJSONtoDb(dataToSave) {
  db = $.couch.db(DATABASE_NAME); 
  for(var i in dataToSave){
    db.saveDoc(dataToSave[i], {     
        success: function(data) {
            console.log("node added succesfully");
        },
        error: function(data){
            console.log("Problem with data" + data);
        }
    });
  }      
}

Where is the problem? Does CouchDB contain any buffer which may be overfilled?

Kim Stebel
  • 41,826
  • 12
  • 125
  • 142
  • Are you just running 2000+ AJAX requests in parallel? Can you run them in batches instead? – Dominic Barnes May 09 '13 at 15:11
  • What happens if you do the same test and not using couchapp and jQuery? Also, can you make use of the bulk support in CouchDb? http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API – Daniel May 10 '13 at 21:20

0 Answers0