Finding a match in an array field Finding a match in an array field mongoose mongoose

Finding a match in an array field


db.collection.find( { field : { $in : array } } ); is not the syntax that you want. That says "Find me the document where this field has one of the list values that I'm going to give you in an array."

You want to use equality while reaching into the array.

db.collection.find( { imageName:theImage } )

This says find me the document where imageName is theImage so this will return the Album (or Albums if a picture can be in more than one album) which contains this image in its imageName array.