//student whose attendance status will change
  var someData = [
      {email: "student2@gmail.com", subject: "chem"},
      {email: "student1@gmail.com", subject: "chem"},
   ];
   
   var sub=someData[0].subject; //chem
   
   //function to extract the emails and saving them in array
   function listEmails(email) {
    let product_names = [];
    for (let i=0; i<email.length; i+=1) {
     product_names.push(email[i].email);
     
    }
    return product_names;
  }
  
//update those student whose email & subject was passed 
     
   const files = await listEmails(someData);//get all the emails
    //Use map iterate through all the mail and update sequentially 
    //condition to check before update if they are student ,subject,email match the parameters passed
    //set those student attendance_status=present
    //promise all is where the magic is happening
   await Promise.all(files.map(async (file) => {
     
    const updatestatus=await Attendance.update(
      { },
      { $set: { "professorclass.$[elem].attendance_status" :  "Present" } },
      {
        multi: true,
        arrayFilters: [ { "elem.role": { $eq: "student" }, "elem.subject": { $eq: sub}, "elem.email": { $eq: file}} ], multi: true
      }
   );
   
   console.log(updatestatus); // it will return if files got modified or not
   console.log(file);//to check which mail
  }));