title: MongoDB - Shell Scripting - $in arguments not working
body: <p>I am using <code>db.system.js.save</code> to save js functions on the server.</p>
  
  <p>I wrote this script so far</p>
  
  <pre><code>function () {
  cursor = db.MyCollection.find({_id: {$in:[arguments]}})
                                               ^ this does not work
          while(cursor.hasNext()){print(cursor.next())};       
  }
  </code></pre>
  
  <p>I am calling it with the following argument <code>findAllDocuments(ObjectId("544a30c80c80d5809180b"),&lt;more objects&gt;);</code>, but it is not working.</p>
  
  <p>Do I have to call it <code>arguments</code> differently? Because <code>arguments[0]</code> is working for example.</p>
  
  <hr>
  
  <p>Edit: For clarification <code>arguments</code> are the parameters of the javascript function.</p>
  
  <p><code>findAllDocuments(ObjectId("544a30c80c80d5809180b"),ObjectId("544a30c80c80d5809180b"), &lt;and more objectIds&gt;);</code>
  If I use it like this it does work, but the arguments length can be variable.</p>
  
  <pre><code>function () {
  cursor = db.MyCollection.find({_id: {$in:[arguments[0],arguments[1]}})
                                               ^ this does work
          while(cursor.hasNext()){print(cursor.next())};       
  }
  </code></pre>
  
  <hr>
  
  <p>EDIT 2: </p>
  
  <p>How can I use the $in correctly in $ref?</p>
  
  <pre><code> cursor = db.MyCollection.find({"trainer" : {
          "$ref" : "Contact",
          "$id" : {$in : [ObjectId("556d901118bfd4901e2a3833")]}
                    ^it executes successfully, but does not find anything
      }})
  </code></pre>