Answer the question
In order to leave comments, you need to log in
How to update a mongo model so that an already updated model is returned?
There is a mongo collection of users.
I know that to get updated data you need to pass options {new: true}
UserModel.update({_id: id}, {name: 'newName'}, {new: true}, function(err, userModel){
////userModel будут с обновленными свойствами
})
UserModel.findById(id, function(err, userModel){
userModel.update({name: 'newName'},{new: true},function(err, result){
//возвращаеться результат операции, а нужна уже обновленная модель
})
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question