{_where : what } traktuje _where jako String literał, który jest odpowiednikiem:{"_where":what} . Dlatego nie otrzymujesz żadnych zaktualizowanych wyników, ponieważ nie ma pola takiego jak _where . Musisz przypisać go w poniższy sposób, aby działał.
exports.updateUsers = function ( user_id, where, what, pass ) {
var _where = 'settings.'+where; //when I use it doesn't update
var update = {};
update[_where] = what;
user.findOneAndUpdate(
{'user_id' : user_id},
update).exec(function(e,d){
pass("ok")
})
};
update[_where] = what; rozwiązuje wartość w _where zmienna.