Deleting specific element of an array of a particular collection - mongoDb
Solution 1:
Try this
Task.updateOne(
{ _id: taskId },
{
$pull: { comments: { 'comment_id': commentId } }
}
);
Also MongoDB embraces camelCase, so renaming comment_id
field to camelCase (or even simply id
) might improve readability.