I'm using mongoengine and I have a collection Question
.
class Question(Document):
id = StringField(primary_key=True)
answers = EmbeddedDocumentListField(Answer)
class Answer(EmbeddedDocument):
id = StringField(primary_key=True)
uid = StringField()
answer = EmbeddedDocumentField(UserAnswer)
class UserAnswer(EmbeddedDocument):
status = StringField()
Query to update a Answer document in answers field.
Question.objects(id="question_id", answers__uid="uid").update(set__answers__S__answer__status="new_status")
The above query updates only the first matching document in the answers
list.
How can I make it update all matching document in the list?
UPDATE: I tried running the query directly on the mongo shell, it also returned the same result. Is it that because my query is wrong?