title: How to resolve mongodb collection.find before an if state on a post call in node.js
body: <p>I have a problem where I'm trying to query a collection called searchLog (db.search_log = searchLog) using db.collection.find() method but it's not returning anything despite the desired item being in the database. I was googling and it seems like this may be related to the asynchronous nature of the collection.find()... I would like to ask if there is a way around this problem. Thank you.</p>
  <pre><code>  app.post('/', (req, res) =&gt; {
      let bookName = req.body.book;
      let queriedResult = searchLog.find({'name': bookName });
  
      if (!queriedResult) {
          // If queriedResult is not empty, do something
      } else {
          // Do something else
      }    
  });
  </code></pre>