title: Stuck on refactoring Node/Mongo code from callback functions to Promises
body: <p>I wrote a project in node.js, in which asynchrony is achieved via callback functions. However, I have subsequently learnt about Promises, and async/await. Would it be best practice to refactor project code so that I replace all callback functions with async/await?</p>
  <p>Anyway, as a training exercise to myself, I have decided to refactor first to Promises, then to async/await. However, I have some questions about refactoring to promises.</p>
  <p>Now, the following example does not really contain much in the way of 'callback hell' so you may think refactoring to promises is not really necessary, but I am deliberately starting with a straight-forward example. Other parts of my code do contain callback hell.</p>
  <p>So here is an example of a callback function used in a project of mine. When a user selects one of their blogposts and clicks on 'delete', the following code runs (BlogPost is the database collection)</p>
  <pre><code>app.post('/users/login', =(req, res)=&gt;{
      BlogPost.findByIdAndDelete(req.body.idOfPostToBeDeleted, (err, blogpost)=&gt;{
      res.redirect('/');
      console.log(err, blogpost)  
      });
  });
  </code></pre>
  <p>So far, I have refactored it like this.</p>
  <pre><code>app.post('/users/login', (req,res)=&gt;{
      BlogPost
        .findByIdAndDelete(req.body.idOfPostToBeDeleted)
          .then(
          ()=&gt;{res.redirect('/')})
          .catch((error)=&gt;{console.log(error)})
        ;
        }
  </code></pre>
  <p>It seems to work as intended but I feel I haven't done it properly, mainly as I have not created a Promise constructor. All tutorials on this include promise constructors</p>
  <p>Why is this working without a promise constructor?</p>
  <p>What happens to 'then' keyword if it does not have a promise constructor?</p>
  <p>What is best practice here?</p>
  <p>Should I create a promise constructor? What would be the code for that look like exactly?</p>