有没有办法通过 id 或其他字段更新嵌套文档?
我使用“单个文档中的完整树”并且事先不知道嵌套可以有多深。需要更新,例如,回答 {id:'104'}。我可以通过“点表示法”做到这一点,但由于我不知道嵌套的级别(深度),我无法预测我'comment.answers.answers....answers.'
能走多长时间。
有什么方法可以直接查找和更新 id:'104',还是我还需要通过某种深度标记?
{
title:'some title',
comment:
{
id:'101'
author:'Joe',
text:'some comment',
answers:
[
{
id:'102'
author:'Joe',
text:'first answer to comment',
answers:
[
{
id:'103'
author:'Done',
text:'first answer to first answer to comment',
answers:[]
},
{
id:'104'
author:'Bob',
text:'Second answer to first answer to comment',
answers:[]
}
]
},
{
},
{
},
]
}
}