skip to Main Content

How to update array of an object in mongodb?

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}) } }…

VIEW QUESTION
Back To Top
Search