title: Typescript: Mongodb promises
body: <p>This feels like a common enough question, but I can't find it already asked. <em>What should be the Typescript signature</em> of the return value of the function below?</p>
  
  <p>In practise, the right question is perhaps <em>which definitely typed file do I need</em>, as all the ones I looked at seemed to be defining the callback versions of mongo commands?</p>
  
  <p>So far I have <code>tsd</code> installed node, mongodb and bluebird.</p>
  
  <pre><code>function countCountries(db) : *?????* {
      let register = db.collection(REGISTER);
  
      let countries = [an aggregate]
  
      return countries.toArray()
          .then( results =&gt; {
              return db.collection(SUMMARY)
                  .replaceOne( {_id: COUNTRIES}, 
                               {_id: COUNTRIES, 'data': results}, 
                               {upsert: true}  );
          } );
  }
  </code></pre>
  
  <p>I'm using Bluebird more generally in my code including as <code>Promise.promisify(mongoClient.connect);</code>, but here Typescript in inferring a Type of <code>Promise&lt;{}&gt;</code> whereas the promise actually returns a  database connection.</p>