Hey I am trying to allow users to update their emails in an array. I want to update a specific email of theirs if they click on edit. I have the old value and the new value, I know I can do a pull and push but wanted to see if I can do it in a more efficient way with matching the value with the $elemMatch then $set it with the new value? I tried the positional operator but it does not work for just values in an array without a key relationship meaning fieldx: value x... here is my attempt, not sure how to go about it? Other directions are welcomed.
User.findByIdAndUpdate(req.signedCookies.userid,{
emailList: { $elemMatch: {oldEmail, {$set: {req.body.updateEmail}}}}
}, function(err, userX) {});