Commits

Alvaro Videla committed fd9d59b

uses autoconfig for mongodb service

Comments (0)

Files changed (1)

     if (mongodbConn) {
         callback(null, mongodbConn);
     } else {
-        var credentials = cf_utils.getMongoCredentials(null);
-        console.log("MongoDB Credentials: ", credentials);
-
-        var mongoserver = new mongodb.Server(credentials.hostname, credentials.port, {auto_reconnect: true});
-        var db_connector = new mongodb.Db(credentials.db, mongoserver, {});
-
-        db_connector.open(function(err, conn) {
+        mongodb.connect(cf_utils.getMongoUrl(), function(err, conn) {
             if (err) {
                 console.log("Failed to connect to MongoDB: ", err);
                 callback(err, null);
                     mongodbConn = null;
                     console.log("Connection to MongoDB was closed!");
                 });
-
-                if (credentials.username && credentials.password) {
-                    mongodbConn.authenticate(credentials.username, credentials.password, function (err, reply) {
-                        callback(err, mongodbConn);
-                    });
-                } else {
-                    callback(err, mongodbConn);
-                }
+                callback(err, mongodbConn);
             }
         });
     }