Querying MongoDB to match in the first item in an array

I believe you want imgs.0. eg, given your example document, you want to say: db.products.find({"imgs.0": "http://foo.jpg"})

Be aware that referencing array indexes only works for the first-level array. Mongo doesn’t support searching array indexes any deeper.

Leave a Comment