i want to update a date typed document to current date. My schema is
var appEventActivity = mongoose.Schema({
app_key : String,
e_id:String,//event id from appEvent
u_imei:String,//user imei from appUsers
startAt:{type: Date, default : Date.now()},
endAt:{type: Date, default : Date.now()}
});
and my updated part of code is
AppEventActivity.findOneAndUpdate({_id:req.update_event_id},{$currentDate : {endAt:true}}, function(err,data){
if(err)console.log(err);
res.send(data);
});
i have seen add created_at and updated_at fields to mongoose schemas and How do I update a property with the current date in a Mongoose schema on every save? but didn't get success.