These are chat archives for Automattic/mongoose

7th
May 2017
Karol Wójcik
@FieryCod
May 07 2017 15:27

Hello guys supposing i got following code


getOneById(req, res, next) {
  const id = req.swagger.params.id.value;

  Article.findById(id)
    .then((article) => {
      handleNotFound(article, 'Article is not found');
      res.json(article);
    })
    .catch(err => next(err));
}

Do I need catch statement here? I mean when mongoose throws error?

matrixbot
@matrixbot
May 07 2017 15:29
@Algram:matrix.org I have multiple users and a user can have multiple entries. How would you model this? A users collection and an entries collection and then the user has an entries array with ObectID's from the entries collection?