In javascript we can find the location of a specific string within an array using indexOf of
> ["aa","bb"].indexOf("bb")
1
I want to do the same with objectIds in mongodb for example
> ids= db.foo1.distinct('_id');
[
ObjectId("50d38d775f2b6c6e3393d6b0"),
ObjectId("50d38d835f2b6c6e3393d6b1")
]
> id0=db.foo1.findOne()._id
ObjectId("50d38d775f2b6c6e3393d6b0")
I am looking for a way to do something like ids.indexOf(id0) 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.