I have developed a mean stack application. I am trying to update a record with a null value for the Date field. This is working fine on my localhost but not on my server (Aws Ec2). It contains the previous value before the update.
I have also tried 'undefined' but still same issue.
Visit mongodb set null in update
router.put('/editAssign/:id',(req,res)=>{
if(!ObjectId.isValid(req.params.id))
return res.status(400).send('No record with given id : $(req.params.id)');
var assignment = {
name: req.body.name,
code: req.body.code,
appointmentTime: req.body.appointmentTime,
scheduledTime:req.body.scheduledTime,
countEndTime: null
};
Assignment.findOneAndUpdate(req.params.id,{$set:assignment},{new:true},(err,doc)=>{
if(!err)
res.send(doc);
else
console.log('Error in Assignment Update: '+JSON.stringify(err,undefined,2));
});
});
I expect it to work on my server too.