// change code According to your data
// Create your own Schema & import
import RegisterSchemaModel from '../schema/RegisterSchema.js';
router.post("/api/admin/epadmin",(req, res) => {
//You can pass req.body directly or you can separate object
const uData = {"name":req.body.name,"lname":req.body.lname,"mobile":req.body.mobile,"address":req.body.adddress,"city":req.body.city,"gender":req.body.gender}; // Data to be Updated
const cData = {"email":req.body.email}; // Conditional Data or Unqiue Key to fetch
const updatedUser = RegisterSchemaModel.findOneAndUpdate(cData, uData,{new:true}).then((result)=>{
return res.send(result)
}).catch(error => {
return res.status(500).send(error);
});
return res.status(200).json({
message : "Updated user",
data: updatedUser
});
});
Comments
Post a Comment