title: Mongodb delete subdocument
body: <p>I'm trying to delete a subdocument in mongoDb but can't succeed in it. I've tried with $update,$push and $pull but I'm not successful.</p>
  
  <p>I have the following document:</p>
  
  <pre><code>db.users.findOne({"_id": ObjectId("545677a9e4b0e0ef9379993c")})
  {
      "_class" : "com.xxx.xxx.server.da.User",
      "_id" : ObjectId("545677a9e4b0e0ef9379993c"),
      "bookSummaries" : [
          {
              "_id" : ObjectId("545677e7e4b0e0ef9379993d"),
              "isbn" : "2746969644"
              "title": "test title"
          },      
          {
              "_id" : ObjectId("546a522a44ae4f5e652fdca7"),           
              "loanSummaries" : [
                  {
                      "loanStatus" : "REQUESTED",
                      "loanId" : "5473992044aec466a619290c"
                  },
                  {
                      "loanStatus" : "REQUESTED",
                      "loanId" : "5473997d44aec466a619290d"
                  },
                  {
                      "loanStatus" : "REQUESTED",
                      "loanId" : "547605a744ae0f0d558ae757"
                  }
              ],
              "testArray" : [
                  {
                      "title" : "Back to the future",
                      "id" : "test"
                  },
                  {
                      "title" : "Back to the future",
                      "id" : "test2"
                  },
                  {
                      "title" : "Back to the future",
                      "id" : "test3"
                  },
                  "test ",
                  "test ",
                  "test 2",
                  "test 2",
                  {
                      "loanStatus" : "REQUESTED"
                  }
              ],
              "title" : "Back to the future"
          }
      ]
  }
  </code></pre>
  
  <p>and I'm trying to create the queries to:</p>
  
  <ol>
  <li>delete the whole "testArray" subdocument for only this specific subdocument</li>
  <li>delete a specific loanSummaries give its loanId for this specific subdocument</li>
  </ol>
  
  <p>Can you help me creating those queries? I've seen several post like this one, but it is not the same problem.</p>
  
  <p>Thanks a lot</p>