Messages.update(
{_id: docId, "messages.senderId": friendId},
{
$set: {"messages.$[elem].read": true}
},
{
multi: true,
arrayFilters: [{"elem.senderId": friendId}]
},
(err, result) => {
if (err) {
return res.status(500).json({message: "Something error occured" + err})
} else {
return res.status(200).json({message: "Successfully", result})
}
}
)
when this command execute I get an error.
Could not find path "messages.0.senderId" in schema" and my schema is
const Schema = new mongoose.Schema({
conversations: Array,
messages: Array
})
How can solve this problem?, please, help me.
i follow this solution but not work.