Using save function inserting the data using post method, in the same method need to get same json data what we inserted document with an id
apiRoutes.post('/doctor', function(req, res){
if(!req.body.Name || !req.body.password){
res.json({success: false, msg: 'please pass the username and password'});
}else{
var newUser = new Doctor({
Name:req.body.Name,
password : req.body.password,
});
newUser.save(function(err){
if(err){
res.json({success: false, msg :'username alredy existes'});
}else{
res.json({success: true, msg : 'Successfull created user'});
}
});
}
});
In the res.json need to return the same document name and password with _id of the documnet