title: How to return the ObjectId or _id of an document in MongoDB? and error "$in needs an array"
body: <p>I have a document in MongoDB and I would like to get the ObjectId of this document, but I did not find so far a method that does this to me. </p>
  
  <p>Example of query :</p>
  
  <pre><code> user= db.users.find({userName:"Andressa"})
  </code></pre>
  
  <p>This returns this :</p>
  
  <pre><code> { "_id" : ObjectId("53b1c579bdf3de74f76bdac9"), "userid" : 0, "userName" : "Andressa", "userEmail" : "dessa_beca@hotmail.com", "teams" : [ 1, 2, 3 ] }
  </code></pre>
  
  <p>I want get the ObjectId to do another query . </p>
  
  <p>Example:</p>
  
  <pre><code> userID =  `user._id();` //but this does not work, of course, its an example
  </code></pre>
  
  <p>So, I could user the ObjectId to do another query like this:</p>
  
  <pre><code> userFind = db.users.find({_id: userID})
  </code></pre>
  
  <p>UPDATE: 
        This code :</p>
  
  <pre><code> db.teams.find({_id:{$in: user.teams}})
  </code></pre>
  
  <p>returns this error: </p>
  
  <pre><code>error: {
      "$err" : "Can't canonicalize query: BadValue $in needs an array",
      "code" : 17287
  </code></pre>
  
  <p>Does someone know it? </p>