title: Deleting the document according to the condition
body: <p>Assume I have db as;</p>
  
  <pre><code>{
    id: 1,
    address: 
      [
        {type: "home" , street: ""},  
        {type: "work" , street: ""},
        {type: "school" , street: ""}
      ]
  }
  </code></pre>
  
  <p>I want to delete some <code>address</code> objects according to their type. </p>
  
  <p>For example to delete <code>type: "school"</code> with <code>id : 1</code> I wrote a query as;</p>
  
  <pre><code>db.collection.update({ "id" : 1}, {$pull : {"address" : {"type" : "school"}}}
  </code></pre>
  
  <p>By this way I can delete each object of the <code>address</code> field.</p>
  
  <p>But what I wonder is; Is it possible to delete the document when query deletes the last object of the <code>address</code>.</p>
  
  <p>Let me clarify by an example;</p>
  
  <p>collection has;</p>
  
  <pre><code>{
    id: 1,
    address: 
      [
        {type: "school" , street: ""}
      ]
  }
  </code></pre>
  
  <p>query is;</p>
  
  <pre><code>db.collection.update({ "id" : 1}, {$pull : {"address" : {"type" : "school"}}}
  </code></pre>
  
  <p>the result of the query, document becomes;</p>
  
  <pre><code>{
    id: 1,
    address: 
      [
  
      ]
  }
  </code></pre>
  
  <p>What I want is delete the <code>document</code> with <code>id:1</code> and get nothing as a result of the query.</p>
  
  <p>Is it possible to achieve this?</p>