title: MongoDB Connection String to Replica Set
body: <p>I am looking at <a href="http://mongodb.github.io/node-mongodb-native/driver-articles/mongoclient.html" rel="noreferrer">http://mongodb.github.io/node-mongodb-native/driver-articles/mongoclient.html</a> and when you scroll to the section &quot;A replicaset connect using no acknowledgment by default and readPreference for secondary&quot;</p>
  <p>it stated a connection string to replica set like this:</p>
  <pre><code>MongoClient.connect(&quot;mongodb://localhost:30000,localhost:30001/integration_test_?w=0&amp;readPreference=secondary&quot;, function(err, db) {
  
  }
  </code></pre>
  <p>I do not understand why we need to specify <code>2 hosts</code>. 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 <code>3 hosts</code> in a replica set and this connection string only specified <code>2 hosts</code>.</p>
  <p>In addition, why the connection string is not stating the &quot;replicaSet&quot; ?</p>