У меня есть объект ниже. «questions» - это имя документа, и каждый вопрос имеет вложенный массив свойств типа «answers», где некоторые ответы имеют статус вызова свойства.
questions = [
{
"_id": "idq1"
"author" :"auth1"
"Answers": []
},
{
"_id": "idq2"
"author" :"auth2"
"Answers": [
{
"author": "auth1",
"comments" [...],
"status" : "1"
},
{
"author": "auth2",
"comments" [...],
},
{
"author": "auth3",
"comments" [...],
"status" : "0"
}
]
}
]
Мне нужно обновить все вложенные Answers.status = "1" , где длина ответов> 0 и вложенный элемент status не существует. поэтому результат будет:
questions = [
{
"_id": "idq1"
"author" :"auth1"
"Answers": []
},
{
"_id": "idq2"
"author" :"auth2"
"Answers": [
{
"author": "auth1",
"comments" [...],
"status" : "1"
},
{
"author": "auth2",
"comments" [...],
"status" : "1"
},
{
"author": "auth3",
"comments" [...],
"status" : "0"
}
]
}
]