I have this Mongoose query:
Posts.updateOne({ _id: fields.opin_id, "comments._id" :
fields.comment_id, "comments.user_id" : fields.user_id}, {$set:
{"comments.$.body" : fields.comment } },......
Where comments is part of an array. What I am trying to do is match one element of the array by both comment_id, and user_id, but when I update said array, it is always the first element with user_id being updated. comments._id is ignored. I already tried
$and: [{"comments._id" :
fields.comment_id}, {"comments.user_id" : fields.user_id}]
What am I doing wrong?