title: How To Delete Mongo Object (nested 2 arrays down) without knowing its position?
body: <p>I need to remove one of the 'answers' objects nested in the Doc below. I have the text of the answer I'm looking for. I don't have the index of the question OR the answer that I need to drill down into the arrays.</p>
  
  <p>For example, I know that the text of the question I'm trying to drill down into is "This is a question." and the answer I want to delete is "Answer One".</p>
  
  <p>How would you go about doing that?</p>
  
  <p>Here's the sample MongoDB Doc:
  (Quizzes have Questions; Questions have Answers)</p>
  
  <pre><code>{
      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: "categoryTWO"}
          ]
        }
      ],
    }
  </code></pre>
  
  <p>When I was deleting an item that was nested a single level down (in this case, a question), I was able to do it with a query like:</p>
  
  <pre><code>    Quizzes.update(
        { _id: quizID, 'questions.text': questionText },
        { $pull: { questions: {text: questionText }}}
      );
  </code></pre>
  
  <p>(as described here: <a href="http://docs.mongodb.org/manual/core/update/#Updating-ModifierOperations" rel="nofollow">http://docs.mongodb.org/manual/core/update/#Updating-ModifierOperations</a> , in the section titled "Update an Element without Specifying Its Position")</p>
  
  <p>I tried expanding that to something like:</p>
  
  <pre><code>Quizzes.update(
    { _id: quizID, 'answers.text': answerText },
    { $pull: { questions: {text: questionText {answers: {text: answerText }}}}}
  );
  </code></pre>
  
  <p>but didn't have any luck.</p>
  
  <p>Any ideas would be greatly appreciated.</p>