Draculater
Draculater

Reputation: 2278

Document will not update and does not return error. Corrupt?

One particular document will not update, while this same query updates any other _id which I query:

Category.findOneAndUpdate(
    {_id : req.params.id},
    {parent : req.body.parent},
    function(err,obj){
        console.log(err,obj)
        if(err) 
            res.status(500).send(err);
        else
            res.send(200);
    }
)

The callback does not return an error. It's the same behavior as success or document not found.

Also, when I run a simple .find({_id:id}) it finds the document, but updates to that same id don't work.

Upvotes: 0

Views: 59

Answers (1)

pl47ypus
pl47ypus

Reputation: 401

try adding the following code to monitor errors

connection.on("error", function(err){
  console.dir(err);
});

also, look here http://mongoosejs.com/docs/guide.html#safe

Upvotes: 2

Related Questions