As the title suggests, I have a document that contains an array of objects (comments) within an array of objects (notes). Users can comment on each note, but I’m also trying to add a delete function to remove the comments on each note.
scheduleCollection.update_one({'date': date},
{'$pull': {"note.$": {"comment.$.commentId": commentId}}}):
This is what I currently have, but I’m receiving this error:
The positional operator did not find the match needed from the query., full error: {‘index’: 0, ‘code’: 2, ‘errmsg’: ‘The positional operator did not find the match needed from the query.’}
I’ve tried various combinations within the $pull but haven’t been successful.
The data structure looks something like:
{
"date": "03-31-2022",
"note": [{
"comment": [{
"commentId": "uuid",
"comment": "etc"
}]
}]
}
2
Answers
Was the solution that I came to.
see if it helps:
OR: