exports.getViewownerdata = (req,res,next)=>
{
const OwnerId= req.body._id;
const mownername = req.body.ownername;
const ownertype = req.body.ownertype;
const owneraddress = req.body.owneraddress;
const propertymanage = req.body.propertymanage;
OwnerModel.findById(OwnerId)
.then(owner=>{
owner.ownername = mownername;
owner.ownertype = ownertype;
owner.owneraddress = owneraddress;
owner.propertymanage = propertymanage;
return owner.save()
})
.then(result=>{
res.render('/user/home_single');
})
.catch(err=> {
errormessage =err;
res.redirect('/home');});
}
Hi @Rout_Jagan - welcome to community!
I can see the code you’ve posted, but you haven’t asked a question or stated what’s not working. If you’d like a response, please tell us what you want to know!
@Mark_Smith sir please reply
i want to fetch only one data/element of collection but it retrives all data.
for example : a user f_name ,l_name,age,mobilenumber are inserted in a single row/collection . i want to fetch each element by its id. i have tried in the above codes but i am unable to fetch it to show in the frontend/userside . please suggest me how to correct it. i am using mongoose,expressjs,pug with mvc.
I implemented a few examples with Node.js & MongoDB back in the days. It’s not with Mongoose but I hope this gives you some insights: helloworldMongoNode/forecast.js at master · MaBeuLux88/helloworldMongoNode · GitHub