title: How to pull specific element in embedded document in mongoDB
body: <p>I have a MongoDB embedded document where it has many documents in arrays.</p>
  
  <p>EX:</p>
  
  <pre><code>{
      "_id" : ObjectId("594b7b7d4064e264420e38d0"),
      "UnitId" : "594b75d44064e264420e3869",
      "UnitName" : "PARKING",
      "UnitIcon" : "./upload/file-1498117588607.jpg", 
      "Stream" : {
          "_id" : ObjectId("594b7b7d4064e264420e38d1"),
          "Types" : [ 
              {
                  "TypeId" : "594b9a884064e264420e3b56",
                  "TypeName" : "TR/RC",
                  "Travel" : false
              }, 
              {
                  "TypeId" : "594b9a844064e264420e3b55",
                  "MaterialStreamName" : "RW",              
                  "Travel_Required" : false
              }, 
              {
                  "TypeId" : "594b9a9d4064e264420e3b58",
                  "TypeName" : "ST",               
                  "Travel_Required" : true
              }, 
              {
                  "TypeId" : "594b9a764064e264420e3b53",
                  "TypeName" : "FD",               
                  "Travel_Required" : true
              }
          ]
      }   
  },{
      "_id" : ObjectId("594b7b7d4064e264420e38d1"),
      "UnitId" : "594b75d44064e264420e3870",
      "UnitName" : "CAFE",
      "UnitIcon" : "./upload/file-1498117588608.jpg", 
      "Stream" : {
          "_id" : ObjectId("594b7b7d4064e264420e38d2"),
          "Types" : [ 
              {
                  "TypeId" : "594b9a884064e264420e3b56",
                  "TypeName" : "TR/RC",
                  "Travel" : false
              }, 
              {
                  "TypeId" : "594b9a844064e264420e3b55",
                  "MaterialStreamName" : "RW",              
                  "Travel_Required" : false
              }, 
              {
                  "TypeId" : "594b9a9d4064e264420e3b58",
                  "TypeName" : "ST",               
                  "Travel_Required" : true
              }, 
              {
                  "TypeId" : "594b9a764064e264420e3b53",
                  "TypeName" : "FD",               
                  "Travel_Required" : true
              }
          ]
      }   
  },{
      "_id" : ObjectId("594b7b7d4064e264420e38d2"),
      "UnitId" : "594b75d44064e264420e3870",
      "UnitName" : "CAFE",
      "UnitIcon" : "./upload/file-1498117588608.jpg", 
      "Stream" : {
          "_id" : ObjectId("594b7b7d4064e264420e38d3"),
          "Types" : [                 
              {
                  "TypeId" : "594b9a9d4064e264420e3b58",
                  "TypeName" : "ST",               
                  "Travel_Required" : true
              },     
              {
                      "TypeId" : "594b9a884064e264420e3b56",
                      "TypeName" : "TR/RC",
                      "Travel" : false
                  }, 
                  {
                      "TypeId" : "594b9a844064e264420e3b55",
                      "MaterialStreamName" : "RW",              
                      "Travel_Required" : false
                  }, 
                  {
                      "TypeId" : "594b9a764064e264420e3b53",
                      "TypeName" : "FD",               
                      "Travel_Required" : true
                  }
              ]
          }   
      }
  </code></pre>
  
  <p>I have many documents with the combination of UnitID and  TypeID (inside Types object). I have to delete that Type element by match UnitId and TypeID. I have used $pull but didn't achieve. </p>
  
  <pre><code>    db.getCollection('units_details').update(
      { "UnitId" : "594b75d44064e264420e3870","Stream[0].Types.$.TypeID" : "594b9a884064e264420e3b56"    }, 
      { $pull: { "Stream[0].Types"            
                   "TypeId" : "594b9a884064e264420e3b56",
                          "TypeName" : "TR/RC",                            
                          "Travel" : false
            } }} ,{multi:true}
  
      );
  </code></pre>
  
  <p>How to achieve the delete the element inside that types array where that Type order in Types array is changing.</p>