I have this code inside of a route and when I run the debugger, the theDocu2.save();
function is being run and then the socket emit but I never see the $set
run which sets the new mongoose values. Any reason for this? Also, in the debugger, values like bidTime
and bidAmount
are equal to the previous values that were set the last time this route was run.
User.findByIdAndUpdate(req.session.passport.user, {
$set: {
bidDetails: {
bidAmount: req.body.bidAmount,
bidLocation: 'Market Square',
bidTime: moment().format()
}
}
}, function(err, theDocu2) {
if (err) {
return console.log(err);
}
theDocu2.save();
io.to(theDocu2.email).emit('activeBid', {
activeBid: req.body.bidAmount,
bidTime: theDocu2.bidDetails.bidTime
});
});
via kolbykskk
No comments:
Post a Comment