I am looking at http://mongodb.github.io/node-mongodb-native/driver-articles/mongoclient.html and when you scroll to the section "A replicaset connect using no acknowledgment by default and readPreference for secondary"
it stated a connection string to replica set like this:
MongoClient.connect("mongodb://localhost:30000,localhost:30001/integration_test_?w=0&readPreference=secondary", function(err, db) {
}
I do not understand why we need to specify 2 hosts
. I thought the MongoDB documentation already stated that the replica set is transparent to client. That means, the client just need to connect to the primary replica set and MongoDB will do the job. Hence, the connection should just contain 1 host. MongoDB doc stated that there must be at least 3 hosts
in a replica set and this connection string only specified 2 hosts
.
In addition, why the connection string is not stating the "replicaSet" ?