title: Mongodb Node.js getting query result out of a function
body: <p>I just want the function
  to return the result of a mongodb query, and I can't get it to not return a promise.</p>
  <pre><code>function findResult(sequence){
      return dbo.collection(&quot;counter&quot;).findOne({ name: sequence })
  }
  </code></pre>
  <p>I've tried so many things like await, callbacks using .then etc.
  Examples would be really appreciated, can't find any up-to-date examples on how to do this.</p>
  <p>Edit:</p>
  <p>I'm using the result to auto increment.</p>
  <pre><code>function findResult(sequence) {
         return dbo.collection(&quot;counter&quot;)
             .findOne({ name: sequence })
             .then(function (res) {
                 return res;
             })
             .catch(function (err) {
             });
     }
  
     let result = findResult('test');
     console.log(result)
  </code></pre>
  <p>And this still returns
  <code> Promise { &lt;pending&gt; }</code></p>