title: db.collection.remove() not removing document
body: <p>I have a collection TextDocuments</p>
  
  <pre><code>/* 0 */
  {
   name:"doc2",
   pages:[{
   pageNumber:"1",
   text:"This is first page text",
  
  
   },{
   pageNumber:"2",
   text:"This is second page text",
  
  
   },{
   pageNumber:"3",
   text:"This is third page text",
  
  
   }]
   }
   /* 1 */
   {
   name:"doc2",
   pages:[{
   pageNumber:"1",
   text:"This is first page text",
  
  
   },{
   pageNumber:"2",
   text:"This is second page text",
  
  
   },{
   pageNumber:"3",
   text:"This is third page text",
  
  
   }]
   }
  </code></pre>
  
  <p>I want to remove documents from collection TextDocuments which has name = doc2
  when Am running following query in mongo shell</p>
  
  <pre><code>rohitkumar@ubuntuhost:~$ mongo
  &gt; use mydb
  switched to db mydb
  &gt; db.TextDocuments.remove({"name":"doc2"})
  WriteResult({ "nRemoved" : 1 })
  &gt;
  </code></pre>
  
  <p>But in second scenario 
  I have created a shell script </p>
  
  <pre><code>//File name collectionRemove.js
      var db =  connect("localhost:27017/mydb");
      var names= ["doc1","doc2"];
  
  
      for(i=0;i&lt;names.length;i++){
  
      db['TextDocuments'].remove({"name":names[i]});
  
      }
  </code></pre>
  
  <p>when executing this from mongo shell using below command </p>
  
  <pre><code>rohitkumar@ubuntuhost:~$mongo mydb  --eval "load('collectionRemove.js')"
  </code></pre>
  
  <p>documents are not getting removed. Any solution?</p>