The $ operator is what you are looking for:
db.test.insert({key: "blah",list :[{id:1},{id:2}]}) db.test.find({'list.id' : 1},{'list.$': 1 })
If you do not need the _id of the document, you can also exclude it:
db.test.find({'list.id' : 2},{'list.$': 1 , _id: 0})
For more information, see the documentation for $ operator and read operations in general.
source share