As you ony match against one field, you only have to express the path to your field using dot-notation:
> db.user.find({"profile.wishlist._id": 2})
As explained in the MongoDB documentation, for arrays (like wishlist) this will match a document if any subdocument in the array match the field value.
Please note that if you need to match against several fields, you need to use either:
$elemMatch if all matching fields should belong to the same subdocument;
- or multiple fields expressed using the dot-notation if the various fields don't need to match against the same subdocument.
Please compare the output of those two queries to get a grasp on this:
> db.user.find({"profile.wishlist._id": 2, "profile.wishlist.name": "a1"})
// ^ ^^
// will return your document even if the was no
// subdocument having both _id=2 and name=a1
> db.user.find({"profile.wishlist": {$elemMatch: { _id: 2, name: "a1"}}})
// ^ ^^
// no result as there was no subdocument
// matching _both_ _id=2 and name=a1