diff --git a/lib/index.js b/lib/index.js index 7fad116..4af86f1 100644 --- a/lib/index.js +++ b/lib/index.js @@ -18,7 +18,7 @@ var connection_queue = async.queue(function(task, callback) { if(dbs[task.name]) { callback(null, dbs[task.name]); } else { - new mongo.Db(task.name, new mongo.Server(options.host, options.port)).open(function(err, db) { + new mongo.Db(task.name, new mongo.Server(options.host, options.port, {auto_reconnect: true}), {strict: false}).open(function(err, db) { if (err) { callback(err); } else { @@ -157,7 +157,8 @@ var insert = function(dbName, collection, metric, callback) { return callback(err); }; - db.createCollection(collection, colInfo, function(err, collClient) { + db.collection(collection, colInfo, function(err, collClient) { + if (err) throw err; collClient.insert(metric, function(err, data){ if (err) callback(err); if (!err) callback(false, collection);