title: Using objectId as an array in mongodb
body: <p>In javascript we can find the location of a specific string within an array using indexOf of </p>
  
  <pre><code>&gt; ["aa","bb"].indexOf("bb")
  1 
  </code></pre>
  
  <p>I want to do the same with objectIds in mongodb for example </p>
  
  <pre><code>&gt; ids= db.foo1.distinct('_id');
  [
          ObjectId("50d38d775f2b6c6e3393d6b0"),
          ObjectId("50d38d835f2b6c6e3393d6b1")
  ]
  &gt; id0=db.foo1.findOne()._id
  ObjectId("50d38d775f2b6c6e3393d6b0")
  </code></pre>
  
  <p>I am looking for a way to do something like <strong>ids.indexOf(id0)</strong> that will give me the location of id0 within ids. I can convert everything to strings and then use the indexOf but I was hoping to find a simpler way to do this.</p>