0

I have some controllers where many callback functions are used instead of async await. I am using bluebird promise library to promisify. In callback function there are many mongoose methods like find, findOneAndUpdate. But there is no option to append Async in front of theses methods. Is there any way to handle this. Or I'm I doing this the wrong way?

app.get('/acceptTeam/:TeamID', (req, res) => {
    TeamTerms.findOneAndUpdate({ TeamID: req.params.TeamID }, { status: 'ACCEPTED' }).then(() => ).catch((err) => {
      console.log(err);
      return res.status(500).send();
    });
  });
  • mongoose supoorts promises so you dont need bluebird or other libraries – Shubham Dixit Feb 27 '20 at 09:21
  • Does this answer your question? [How do I convert an existing callback API to promises?](https://stackoverflow.com/questions/22519784/how-do-i-convert-an-existing-callback-api-to-promises) – blaz Feb 27 '20 at 09:22
  • mongoose support promises but they are relatively slower than bluebird – ananyabingo Feb 27 '20 at 09:23

0 Answers0