Answer the question
In order to leave comments, you need to log in
Why isn't data being updated in MongoDB?
var User = require('../../models/user')
var mongoose = require('mongoose')
module.exports = function (req, res) {
var post = req.body // post.name === new value
User.findById(req.user._id, function (err, user) {
if(err) return console.log(err);
user.data.moneySource[post.index].name = post.name;
user.save(function (err) {
if(err) return console.log(err)
console.log(user.data.moneySource[post.index].name) // it returns NEW value
})
})
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