Search code examples
node.jsmongodbmongodb-.net-driver

Simple autosharing in MongoDb


I'm working on Node Js. Well my question is simple, I read that MongoDB, generates a autosharing, my question is if I do this

var myDB = [ 'mongodb://127.0.0.1:27017/test',
    'mongodb://otherServer:27017/other',
    'mongodb://myMongo:27017/myDb','
    'mongodb://other:27017/db'];
MongoClient.connect(myDB.join(), function(err, db) {
    if(err) throw err;
});

Autosharing is generated without nececidad to modify the configuration of the servers in mongodb?


Solution

  • Are you trying to connect to a replica set? If so, this is how you form the connection string:

    var mongoURI="mongodb://myUsrName:pass@mongoServer-001.company.com:27017,mongoServer-002.company.com:27017,mongoServer-003.company.com:27017/myDBname";