我需要删除嵌入在下面的Doc中的一个"答案"对象.我有我正在寻找答案的文字.我没有问题的索引或我需要深入研究数组的答案.
例如,我知道我试图深入研究的问题是"这是一个问题".我想删除的答案是"答案一".
你会怎么做呢?
以下是MongoDB Doc示例:(测验有问题;问题有答案)
{
name: "Sample Quiz",
categories: [
{ name: "testcategory1", description: "this is a test category" }
,{ name: "categoryTWO", description: "the second category" }
],
questions: [
{ text: "This is a question."
,answers: [
{text: "Answer One", affected_categories: "testcategory1"}
,{text: "Answer Two", affected_categories: "testcategory1"}
,{text: "Answer Three", affected_categories: "categoryTWO"}
]
}
,{ text: "This is the second question."
,answers: [
{text: "Mepho One", affected_categories: "testcategory1"}
,{text: "Answer Toodlydoo", affected_categories: "testcategory1"}
,{text: "Lehmen Sumtin", affected_categories: …Run Code Online (Sandbox Code Playgroud)