Hello! I am trying to update each of the dates of some documents by means of updateMany by adding a certain number of days, but I don’t know if it is not possible or if I am not doing something right, I leave you part of the code:
Exemple :
I have this document:
{
appointmentObservations: "Hello",
appointments: [
{
uid: '123445667',
date: '2022-04-10T22:00:00.000Z'
}
]
}
If i add 1 day i want this:
{
appointmentObservations: "Hello",
appointments: [
{
uid: '123445667',
date: '2022-04-11T22:00:00.000Z' ======> one day added
}
]
}
This is my trying:
await Appointments.updateMany(
{
"appointments.UIDRecurrent": uid,
"appointments.date": { $gte: new Date(date) }
},
{
"$set": {
"appointmentObservation": appointmentObservation,
"appointments.0.busyDays": busyDays,
"appointments.0.recurrentTitle": recurrentTitle,
"appointments.0.UIDRecurrent": UIDRecurrent,
"appointments.0.date": {
"$add": ["$appointments.0.date", 1000 * 60 * 60 * 24]
}
}
})
What am I doing wrong? can it be done somehow?
Thank you very much!!