title: Determine if MongoClient instance is already connected
body: <p>I have this bit of code to check if my MongoClient is already connected:</p>
  
  <pre><code> connect(): Promise&lt;null&gt; {
      const self = this;
  
      if (this.client &amp;&amp; this.client.isConnected()) {
        return Promise.resolve(null);
      }
  
      return MongoClient.connect(this.uri).then(function (client) {
        const db = client.db('local');
        self.client = client;
        self.coll = db.collection('oplog.rs');
        return null;
      });
    }
  </code></pre>
  
  <p>The <strong>problem</strong> is that the isConnected method takes some mandatory arguments:</p>
  
  <pre><code>    isConnected(name: string, options?: MongoClientCommonOption): boolean; 
  </code></pre>
  
  <p>here is the info:</p>
  
  <p><a href="http://mongodb.github.io/node-mongodb-native/3.0/api/MongoClient.html#isConnected" rel="noreferrer">http://mongodb.github.io/node-mongodb-native/3.0/api/MongoClient.html#isConnected</a></p>
  
  <p>so do I need to pass anything other than the database name? <strong>What if I don't know what database it might be connected to?</strong></p>
  
  <p>When I debug at runtime, I only see an options argument (just 1 argument, not two):</p>
  
  <p><a href="https://i.stack.imgur.com/N4MYa.png" rel="noreferrer"><img src="https://i.stack.imgur.com/N4MYa.png" alt="enter image description here"></a></p>
  
  <p>(look at the isConnected method on the far right in the image).</p>