One thing I would like to point out: medicalObj will be an array of objects. I would think that you would want to add jobName: andrea to a specific array contained within the job, so this is what I did in my testing:
Exercise.findOne({area: area}, function(e,r){
r.medicalObj.forEach(function(demo){
if (demo.demoName == "test") {
demo.job.push({jobName: "Andrea"});
r.save(function(err, res){
console.log(err, res);
});
});
});
If you want to insert only name_name: βAndreaβ, if it does not exist, you can easily add line-by-line checking:
Exercise.findOne({area: area}, function(e,r){
r.medicalObj.forEach(function(demo){
if (demo.demoName == "test") {
var found = false;
demo.job.forEach(function(jobs){
if (jobs.jobName == "Andrea") found == true;
});
if (found == false) {
demo.job.push({jobName: "Andrea"});
r.save(function(err, res){
console.log(err, res);
});
};
};
});
});