So I know this question has been asked many times but I\'ve looked it up for over 30 minutes and I honestly can\'t find what I\'m doing wrong.
I want to update my mongo
As noted in the docs for update, if you don't want to provide a callback, you need to call exec
on the returned Query
to execute it:
To update documents without waiting for a response from MongoDB, do not pass a callback, then call
exec
on the returned Query
So either chain an exec
call on your update
or provide a callback:
function updateUsers(){
UserModel.update({}, {$set: {userName: 'JOHN CENA'}}, {multi:true}).exec();
}
OR
function updateUsers(){
UserModel.update({}, {$set: {userName: 'JOHN CENA'}}, {multi:true},
function(err, numAffected) {...});
}