title: Mongoose with ReplicaSet on Atlas
body: <p>I have a replica set on MongoDB Atlas and this is my mongo shell connection string which connects perfectly:</p>
  
  <pre><code>$ mongo "mongodb://MY_SERVER-shard-00-00-clv3h.mongodb.net:27017,MY_SERVER-shard-00-01-clv3h.mongodb.net:27017,MY_SERVER-shard-00-02-clv3h.mongodb.net:27017/MY_DATABASE?replicaSet=MY_REPLICASET-NAME-shard-0" --ssl --username MY_USERNAME --password MY_PASSWORD --authenticationDatabase MY_ADMIN_DATABASE
  </code></pre>
  
  <p>How Can I convert it to use in mongoose? How Can I build my uri and options variable?</p>
  
  <p>I tried the following without success:</p>
  
  <pre><code>  // connection string using mongoose:
    var uri = 'mongodb://MY_USER:MY_PASSWORD@' +
      'MY_SERVER-shard-00-00-clv3h.mongodb.net:27017,' +
      'MY_SERVER-shard-00-01-clv3h.mongodb.net:27017,' +
      'MY_SERVER-shard-00-02-clv3h.mongodb.net:27017/MY_DATABASE';
  
    var options = {
      replset: {
        ssl: true,
        authSource: 'MY_ADMIN_DATABASE',
        rs_name: 'MY_REPLICASET_NAME-shard-0'
      }
    };
  
    mongoose.connect(uri, options);
    var db = mongoose.connection;
  </code></pre>
  
  <p>I've tried including user: and pass: on options, removing MY_USER:MY_PASSWORD@ from uri, change rs_name to replicaSet, every unsuccessful attempt. It seems that mongoose is not considering the authSource option.</p>
  
  <p>Using the mongojs, it works fine with the following code:</p>
  
  <pre><code>  // connection string using mongojs:
    var uri = 'mongodb://MY_USER:MY_PASSWORD@' +
      'MY_SERVER-shard-00-00-clv3h.mongodb.net:27017,' +
      'MY_SERVER-shard-00-01-clv3h.mongodb.net:27017,' +
      'MY_SERVER-shard-00-02-clv3h.mongodb.net:27017/MY_DATABASE';
  
    var options = {
      ssl: true,
      authSource: 'MY_ADMIN_DATABASE',
      replicaSet: 'MY_REPLICASET_NAME-shard-0'
    };
  
    var db = mongojs(uri,'', options);
  </code></pre>
  
  <p>But, I need to use mongoose because the ODM in my project.</p>
  
  <p>How can I build my uri and options variable using mongoose?</p>