ネストされたドキュメントを 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:[]
}
]
},
{
},
{
},
]
}
}
Node.JS MongoDB ドライバーを使用しています