|
It's something like as $elemMatch projection works but instead returning the single value it could be return all matches like the follows:
{
|
_id: ObjectId(),
|
zipcode: 63109,
|
dependents: [
|
{ name: "john", school: 102, age: 10 },
|
{ name: "jess", school: 102, age: 11 },
|
{ name: "jeff", school: 108, age: 15 }
|
]
|
}
|
|
var projection = { _id: 0, dependents: { $filter: { school: 102 }}};
|
db.students.find( { zipcode: 63109 }, projection);
|
|
{
|
dependents: [
|
{ name: "john", school: 102, age: 10 },
|
{ name: "jess", school: 102, age: 11 }
|
]
|
}
|
|