S
S
Seva2017-05-18 17:39:20
JavaScript
Seva, 2017-05-18 17:39:20

Why does Mongoose "delete" a document with a non-existent ID?

Good afternoon friends.
Strange things are happening.

function deleteItem(req, res) {
  Goods.findByIdAndRemove(req.params.id, (err) => {
    if (err) {
      res.send({
        success: false,
        error: err
      });
    } else {
      res.send({
        success: true,
        item: req.params.id
      });
    }
  })
}

Delete document - the document is deleted. We delete it again (pass the same _id) - it is deleted again! We change, for example, the last three digits to arbitrary ones (for example, 591dad9a1583ea0d1065d633) - it is "deleted" again! Swears, only if instead of _id to transfer complete garbage, like srthrscsctrshs
What am I doing wrong, what kind of magic?
Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question