I try to update an array of object using MongoDB.
Exemple of object :
[
{
_id: 'ID',
name: 'hello',
org: 'world',
seenBy: [
{
_id: 'ID',
seenAt: 'DATE'
},
...
],
...
}
]
I would like update the Date on seenBy.seenAt. For this, i try this Mongo update :
await Task.updateOne(
{
_id: ctx.task._id,
'seenBy._id': ctx.me._id
},
{
$set: {
"seenBy.$.seenAt": new Date()
}
},
);
But it don't work, and i'm not really understand why. I target the correct item by checking the _id and the seenBy._id, but the new value is never add.
Any one know if i need other operation ? Maybe i'm wrong approch :D
Thank you community !