Skip to content

Latest commit

 

History

History
52 lines (46 loc) · 1.65 KB

api-documentation.rst

File metadata and controls

52 lines (46 loc) · 1.65 KB
The Node.JS MongoDB Driver API
if(numberOfTries <= 0) return callback(new Error("could not connect correctly"), null);

var db = new Db('integration_test_', replSet);
// Print any errors
db.on("error", function(err) {
  console.log("============================= ensureConnection caught error")
  console.dir(err)
  if(err != null && err.stack != null) console.log(err.stack)
  db.close();
})

// Open the db
db.open(function(err, p_db) {
  // Close connections
  db.close();    
  // Process result
  if(err != null) {
    // Wait for a sec and retry
    setTimeout(function() {
      numberOfTries = numberOfTries - 1;
      ensureConnection(test, numberOfTries, callback);
    }, 1000);
  } else {
    return callback(null, p_db);
  }    
})            

}