I need to update the nested subroutine field value like date, tittle .how can I do it?
I used this function below but it doesn’t working well.
const UpdatedPlayer = await PlayersSchemaModule.updateOne(
{
_id: new ObjectId("6579bc2a0629d0fc6892d7cf"),//This is the Player _id
[`info.routine`]:{
$elemMatch: {
_id:new ObjectId("65e3e33baa663fc7b723f003"),//Routine _id
subRoutines: {
$elemMatch :{
subroutineid: new ObjectId("65decbc0fbb14d315faec054")//This is the subroutineid of specific sub-routine which id need to update
}
}
}
}
},
{
$set:{
[`info.routine.$.routine_heading`] : 'This is main routine update heading',// This work
[`info.routine.$.subRoutines.$.date`] : new Date(),//This dosent work but i want it to update the specific sub-routine date
[`info.routine.$.subRoutines.$.tittle`] : "This is new updated tittle of the sub-routine" ,//This dosent work but i want it to update the specific sub-routine tittle
},
}
)
