I would like to update my mongodb using angularjs and nodejs. I would like to update using the id.
I found the following code which updates object with id 1. I would like to pass the id as a parameter and then update the object
module.exports.updateUser = function (req, res) {
// get a user with ID of 1
User.findById(1, function(err, user) {
if (err) throw err;
// change the users location
user.auto = 'true';
// save the user
user.save(function(err) {
if (err) throw err;
console.log('User successfully updated!');
});
});
}
Can you help