title: How to remove a single array element in a specific object in mongodb?
body: <p>i need some help with my Mongo DB request.</p>
  
  <p>This is my document structure:</p>
  
  <pre><code>{
   "username" : "firstUser",
   "email" : "first@email.com",
   "subscriptions" : [
       {
           "subscriptionId" : ObjectId("59f972dfdaca9e39487e3bb4"),
           "someOtherFields" : "otherValue",
           "message" : {
               "contact" : [
                   "first@email.com",
                   "second@email.com",
                   "third@email.com"
               ],
               "subject" : "Mailsubject",
               "content" : "Mailcontent"
            }
       },
       {
           "subscriptionId" : ObjectId("59faf26c8a593b25b8a9a8f7"),
           "someOtherFields" : "otherValue",
           "message" : {
               "contact" : [
                   "first@email.com",
                   "second@email.com",
                   "third@email.com"
               ],
               "subject" : "Mailsubject",
               "content" : "Mailcontent"
            }
       }
  }
  </code></pre>
  
  <p>Now i need to remove one E-Mail address from the <code>subscriptions.message.contact</code> array, where the <code>subscriptions.subscriptionid</code> = <code>ObjectId("59f972dfdaca9e39487e3bb4")</code>.</p>
  
  <p>I tried something like this: </p>
  
  <pre><code>db.getCollection('myCollection').update({
  "subscriptions.subscriptionId" : ObjectId("59f972dfdaca9e39487e3bb4")
  },
  {
      "$pull" : { "subscriptions": {"message.contact" : "first@email.com" }}
  })
  </code></pre>
  
  <p>but it removed all <code>subscriptions</code> with this E-Mail address</p>
  
  <p>Does anyone know, how to solve this problem?</p>