Having a document like this. I would like to change the user’s avatar based on the id. for example if the ID matches fromUser’s ID I would like to change the avatar of that object only. but I’m new to mongo and my query is not working as expected.
await Conversation.updateMany(
{
$or: [
{ type: 'userMsg' },
{ 'participants.fromUser.id': userObject.id },
{ 'participants.toUser.id': userObject.id }]
},
{ $set: { 'participants.user.avatar': avatar } },
);