MongoDB: update error

less than 1 minute read

I try to update MongoDB collection by _id, but it is an ObjectID, I can’t use number _id which I got before to update it, finally, I find the answer: Quora

Users can also override _id to something other than an ObjectID.

var ObjectID = require('mongodb').ObjectID;
 
collection.update({"_id": ObjectID("5703....dd0")}, {$set:{"feedback": body.feedback}}, function(err, result){
    if (err) {
        console.log('Error updating object: ' + err);
        res.send({'error':'An error has occurred'});
    } else {
        console.log('' + result + ' document(s) updated');
        res.send(user);
    }
});

Updated: